General information
Category:
COM/DCOM and OLE Automation
>I am trying to create a Word document and add an image to its header. Below is the code I am using:
>
>
>oWord=CREATEOBJECT("Word.Application")
>WITH oWord
> .Visible=.T.
> .WindowState = wdWindowStateMaximize
> .Documents.Add("f:\contacts\docs\test.dot")
> .ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
> .Selection.InlineShapes.AddPicture FileName:="F:\Contacts\Graphics\ACERO1.BMP"_
> ,LinkToFile:=False, SaveWithDocument:=True
> .Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
>ENDWITH
>
Now that everyone else has told you how to fix the syntax, it's also worth pointing out that you're going the long way around to do this. You don't need to change to Page view and select the header. You can address it directly. Put this inside your WITH, replace all the lines beginning with .ActiveWindow...
oHeader = .ActiveDocument.Sections[1].Headers[1].Range
WITH oHeader
.InlineShapes.AddPicture("F:\Contacts\Graphics\ACERO1.BMP")
.ParagraphFormat.Alignment = wdAlignParagraphCenter
ENDWITH
(Note: this is untested, so you may have to tweak.)
Tamar
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only