xeem22
10-16-2008, 09:59 AM
Hi,
This is my first post, been checking on here before an found loads of answers but for the first time I need some more specific help.
I'm having troubles with a word 2003 macro, basically I want it to insert an image (doing it by link rather than embedding it into the document) have that image appear at the top edge of the page and then go the the next page of the document and repeat this.
This is the code I have so far:
Sub InsertImage()
Dim StartupPath As String
Dim ImagePath As String
StartupPath = Options.DefaultFilePath(wdStartupPath) & "\" 'uses startup path to find qamecanix folder
ImagePath = StartupPath & "ImageSource\"
Page = 1
NPage = Application.ActiveDocument.BuiltInDocumentProperties(14)
Do While Page <= NPage
ActiveDocument.Shapes.AddPicture(FileName:=ImagePath & "QA.eps", _
LinkToFile:=True, SaveWithDocument:=False, _
Left:=CentimetersToPoints(17.1), Top:=0).Select
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext
Page = Page + 1
Loop
End Sub
I have it select the image so that I can name it (haven't implemented that into the code yet)
I'm having 2 problems. The first is that it is inserting the image relative to the margins rather than the page. Looking at the msdn resources, it says it should be the page.
The second is that although it selects the next page along, it inserts the image on the 1st page (on top of the previously inserted image).
Please can anyone help as I've been really struggling with this one.
Thanks!
This is my first post, been checking on here before an found loads of answers but for the first time I need some more specific help.
I'm having troubles with a word 2003 macro, basically I want it to insert an image (doing it by link rather than embedding it into the document) have that image appear at the top edge of the page and then go the the next page of the document and repeat this.
This is the code I have so far:
Sub InsertImage()
Dim StartupPath As String
Dim ImagePath As String
StartupPath = Options.DefaultFilePath(wdStartupPath) & "\" 'uses startup path to find qamecanix folder
ImagePath = StartupPath & "ImageSource\"
Page = 1
NPage = Application.ActiveDocument.BuiltInDocumentProperties(14)
Do While Page <= NPage
ActiveDocument.Shapes.AddPicture(FileName:=ImagePath & "QA.eps", _
LinkToFile:=True, SaveWithDocument:=False, _
Left:=CentimetersToPoints(17.1), Top:=0).Select
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext
Page = Page + 1
Loop
End Sub
I have it select the image so that I can name it (haven't implemented that into the code yet)
I'm having 2 problems. The first is that it is inserting the image relative to the margins rather than the page. Looking at the msdn resources, it says it should be the page.
The second is that although it selects the next page along, it inserts the image on the 1st page (on top of the previously inserted image).
Please can anyone help as I've been really struggling with this one.
Thanks!