Re: Insert picture in a speicific location within a document by Helmut
Helmut
Tue Jun 26 15:24:24 CDT 2007
Hi,
like this:
Sub Macro3()
Dim oShp As Shape
Set oShp = ActiveDocument.Shapes.AddPicture( _
FileName:="C:\Pic\bluehills.jpg", _
Anchor:=ActiveDocument.Paragraphs.Last.Range)
oShp.Top = -300
' ... plus some more
End Sub
' ---------------------------------------
Sub Macro3A()
Dim oShp As Shape
Dim rTmp As Range
ActiveDocument.Bookmarks("\endofdoc").Select
ActiveDocument.Bookmarks("\page").Select
Set rTmp =
Selection.Bookmarks("\page").Range.Paragraphs.First.Next.Range
Set oShp = ActiveDocument.Shapes.AddPicture( _
FileName:="C:\Pic\bluehills.jpg", _
Anchor:=rTmp)
oShp.Top = 100
' ... plus some more
End Sub
There are lots of caveats,
e.g. whether the first paragraph on the last page
(Macro3A) starts on that page.
Therefore I used
Set rTmp =
Selection.Bookmarks("\page").Range.Paragraphs.First.Next.Range
But what if there is only one paragraph on that page?
Or, for Macro3, what if the only paragraph on the
last page starts on the page before?
However, trying one third variation
with what the help says for omitting anchor,
Word crashes.
HTH, nevertheless
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"