Information générale
Catégorie:
COM/DCOM et 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
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement