Subject: RE: Add a watermark while printing a Microsoft Word doc w/LotusScript
I appreciate the code.
I have integrated it as follows… It errors on the line noted with the error:
“Microsoft Word: Command only available in print layout view.”
Sub CallAdobe (doc As NotesDocument)
Print "start Sub CallAdobe"
Dim oldPrinter As String
Dim szFilePath As String
szFilePath = "c:\Documents and Settings\All Users\"
'*** Get a hold of the embedded object and save it as an MS Word document
Forall o In doc.EmbeddedObjects
Set handle = o.activate(False)
If Not Isempty(handle) Then
wfile = handle.SaveAs(szFilePath + "Report.doc")
End If
End Forall
'*** Using the recently saved copy of the Embedded Object (to MS Word)…
Dim WordObj As Variant
Dim worddoc As Variant
'*** Create Adobe Acrobat object
Set AcroApp = CreateObject("AcroExch.App")
'*** Create the word object
Set WordObj = CreateObject("Word.Application")
WordObj.visible = False
'*** Open the Word File
Set worddoc = wordobj.documents.open(szFilePath + "Report.doc",True)
' *** TESTING - set the watermark
WordObj.ActiveDocument.Sections(1).Range.Select
WordObj.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader ' *** ERRORS ON THIS LINE
Selection.HeaderFooter.Shapes.AddTextEffect(PowerPlusWaterMarkObject1, _
"DRAFT", "Arial", 1, False, False, 0, 0).Select
Selection.ShapeRange.Name = "PowerPlusWaterMarkObject1" Selection.ShapeRange.TextEffect.NormalizedHeight = False
Selection.ShapeRange.Line.Visible = False
Selection.ShapeRange.Fill.Visible = True
Selection.ShapeRange.Fill.Solid
Selection.ShapeRange.Fill.Transparency = 0.5
Selection.ShapeRange.Rotation = 315
Selection.ShapeRange.LockAspectRatio = True
Selection.ShapeRange.WrapFormat.AllowOverlap = True
Selection.ShapeRange.WrapFormat.Side = wdWrapNone
Selection.ShapeRange.WrapFormat.Type = 3
'*** Capture the old default printer set-up
OldPrinter = WordObj.ActivePrinter
'*** Set-up the default printer
WordObj.ActivePrinter = "Adobe PDF"
’ WordObj.ActivePrinter.PrinterProperty = PropertyValue
'*** Print to PDF Writer (It must be the default printer)
Call Wordobj.activedocument.PrintOut(0,0,0, "")
'*** Execute a 2 second delay before creating a copy of PDF file. Close Word document.
Sleep (2)
’ Filecopy strPath, szFilePath + "Report - " + doc.ProjectName(0) + “.pdf”
Filecopy "c:\temp\Report.pdf", szFilePath + "Report - " + doc.ProjectName(0) + ".pdf"
Call Worddoc.Close(False)
'*** Capture the old default printer set-up
WordObj.ActivePrinter = OldPrinter
'*** Close the word object
WordObj.Quit(True)
Set wordobj = Nothing
End Sub