Home > Software engineering >  Insert into the WORD OFFICE2003 image problem
Insert into the WORD OFFICE2003 image problem

Time:12-22

 Dim wordDoc As New Word. The Document 
Dim WordApp As Word. Application
Dim pag As Integer

The Set WordApp=New Word. Application
The Set wordDoc=WordApp. Documents. The Open (" c: \ 123. Doc ")
WordApp. Visible=False
WordApp. DisplayAlerts=False

For pag=1 To Selection. Information (wdNumberOfPagesInDocument)
Selection. GoTo I:=wdGoToPage, Name:=pag
If pag=1 Then
ActiveDocument. Shapes. AddPicture FileName:="C: \ yz. GIF", Left:=300, Top:=480, Anchor:=Selection. Range
ElseIf pag=5 Then
ActiveDocument. Shapes. AddPicture FileName:="C: \ yz. GIF", Left:=180, Top:=590, Anchor:=Selection. Range
End the If
Next

WordDoc. Save
WordDoc. Close
WordApp. Quit
The Set WordApp=Nothing
The Set wordDoc=Nothing


The first call when it can be inserted into the picture to the WORD, the second call when I was in the
For pag=1 To Selection. Information (wdNumberOfPagesInDocument)
Error, error message: the remote server does not exist or cannot use,
Not very good at VBA, make for a long time haven't a clue, please have a look, thank you

CodePudding user response:

Word of vba is seldom used,

I guess may be related to the selection, insert try try to revise the selection, after the completion of or: after completion of the first insert can save open once again look at successful, if successful, that is the problem of selection

CodePudding user response:

Upstairs are tried, but also in this way, so only in CSDN ask Daniel,

CodePudding user response:

Selection for activedocument. Shapes

CodePudding user response:

Start recording macros in the Word 2003, manual, complete the required function end record macros, press Alt + F11 key, check just record macro corresponding VBA code,
  • Related