G
Guest
Quick question:
The objective is to insert a full page graphic into a page in a
document. On this page exist a couple of bookmarks which are filled in
later. To build the template...
1. Create the bookmarks on the page where I need them.
2. Insert a Microsoft Word Picture object, size it and place it.
This VBA populates the page - but there's a serious inconsistency.
Sometimes, the graphic goes into an edit mode and prompts me to "Close
Picture". This happens once in every 3 or 4 "loads". Second -
regardless of what I do, the bookmark ends up behind the picture. Can
anyone clue me in as to why this is happening?
Cheers,
Mike
<VBA>
Set g_word = New Word.Application
g_word.Application.ChangeFileOpenDirectory "C:\\Documents and
Settings\\foo\\My Documents\\foobar\\VB"
Set g_doc = g_word.Documents.Add("SampleTemplate")
g_word.Visible = False
Dim shp As Word.Shape
Dim r As Word.Range
Set r = g_doc.Bookmarks.Item("CompanyName").Range
r.Text = "Testing 1234"
g_word.ActiveDocument.Shapes("TitlePageGraphic").Select
Set inlineImg = g_word.Selection.InlineShapes.AddPicture(FileName:= _
"C:\Documents and Settings\foo\My
Documents\foobar\Templates\image2.jpg", _
LinkToFile:=False, SaveWithDocument:=True)
Set shp = inlineImg.ConvertToShape
With shp
..RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
..RelativeVerticalPosition = wdRelativeVerticalPositionPage
..Top = InchesToPoints(0.25)
..Left = InchesToPoints(0.25)
..Height = InchesToPoints(10.5)
..Width = InchesToPoints(8#)
..ZOrder msoSendBehindText
End With
Set tmpImg = Nothing
Set inlineImg = Nothing
g_word.Visible = True
</VBA>
The objective is to insert a full page graphic into a page in a
document. On this page exist a couple of bookmarks which are filled in
later. To build the template...
1. Create the bookmarks on the page where I need them.
2. Insert a Microsoft Word Picture object, size it and place it.
This VBA populates the page - but there's a serious inconsistency.
Sometimes, the graphic goes into an edit mode and prompts me to "Close
Picture". This happens once in every 3 or 4 "loads". Second -
regardless of what I do, the bookmark ends up behind the picture. Can
anyone clue me in as to why this is happening?
Cheers,
Mike
<VBA>
Set g_word = New Word.Application
g_word.Application.ChangeFileOpenDirectory "C:\\Documents and
Settings\\foo\\My Documents\\foobar\\VB"
Set g_doc = g_word.Documents.Add("SampleTemplate")
g_word.Visible = False
Dim shp As Word.Shape
Dim r As Word.Range
Set r = g_doc.Bookmarks.Item("CompanyName").Range
r.Text = "Testing 1234"
g_word.ActiveDocument.Shapes("TitlePageGraphic").Select
Set inlineImg = g_word.Selection.InlineShapes.AddPicture(FileName:= _
"C:\Documents and Settings\foo\My
Documents\foobar\Templates\image2.jpg", _
LinkToFile:=False, SaveWithDocument:=True)
Set shp = inlineImg.ConvertToShape
With shp
..RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
..RelativeVerticalPosition = wdRelativeVerticalPositionPage
..Top = InchesToPoints(0.25)
..Left = InchesToPoints(0.25)
..Height = InchesToPoints(10.5)
..Width = InchesToPoints(8#)
..ZOrder msoSendBehindText
End With
Set tmpImg = Nothing
Set inlineImg = Nothing
g_word.Visible = True
</VBA>