In Word2000 I have a macro that creates a document. After setting up the text I want the macro to insert shapes (pictures) at various places (which works). I want to name each shape (picture) as I insert them. I then want to goto each one by name and set the wrap characteristics, etc. I have enclosed my code which does not seem to work. I'm not sure if it's the naming command that is wrong or the goto command - or - both.
Thank You
'Start Insert Picture Section
If ActiveWindow.View.SplitSpecial = wdPaneNone Then
ActiveWindow.ActivePane.View.Type = wdPrintView
Else
ActiveWindow.View.Type = wdPrintView
End If
Selection.Find.ClearFormatting
With Selection.Find.Font
.Size = 14
.Bold = False
.Italic = False
End With
For I = 1 To hms
With Selection.Find
.Text = Test$(I)
.Replacement.Text = Test$(I)
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveDown Unit:=wdLine, Count:=6
Selection.HomeKey Unit:=wdLine
Dim char As Long
char = Selection.EndOf(Unit:=wdParagraph, Extend:=wdMove)
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Dim MyRange As Range
Set MyRange = ActiveDocument.Bookmarks("\Para"
.Range
ActiveDocument.Shapes.AddPicture FileName:="c:\test\" + Test$(I) + ".jpg" _
, LinkToFile:=False, SaveWithDocument:=True, Left:=36, Top:=200, Width:=288, Height:=169.2, Anchor:=MyRange
ActiveDocument.Shapes(1).Name = Test$(I)
Next
ActiveDocument.GoTo What:=wdGoToObject, Which:=wdGoToFirst, Name:="Shape"
With Selection.ShapeRange
.WrapFormat.Side = wdWrapLeft
.WrapFormat.DistanceTop = InchesToPoints(0)
.WrapFormat.DistanceBottom = InchesToPoints(0)
.WrapFormat.DistanceLeft = InchesToPoints(0.13)
.WrapFormat.DistanceRight = InchesToPoints(0.13)
.WrapFormat.Type = wdWrapTight
End With
For I = 1 To hms - 1
Selection.GoTo What:=wdGoToObject, Which:=wdGoToNext, Name:="Picture"
With Selection.ShapeRange
.WrapFormat.AllowOverlap = True
.WrapFormat.Side = wdWrapLeft
.WrapFormat.DistanceTop = InchesToPoints(0)
.WrapFormat.DistanceBottom = InchesToPoints(0)
.WrapFormat.DistanceLeft = InchesToPoints(0.13)
.WrapFormat.DistanceRight = InchesToPoints(0.13)
.WrapFormat.Type = wdWrapTight
End With
Next
'End Insert Pictures Section
Thank You
'Start Insert Picture Section
If ActiveWindow.View.SplitSpecial = wdPaneNone Then
ActiveWindow.ActivePane.View.Type = wdPrintView
Else
ActiveWindow.View.Type = wdPrintView
End If
Selection.Find.ClearFormatting
With Selection.Find.Font
.Size = 14
.Bold = False
.Italic = False
End With
For I = 1 To hms
With Selection.Find
.Text = Test$(I)
.Replacement.Text = Test$(I)
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveDown Unit:=wdLine, Count:=6
Selection.HomeKey Unit:=wdLine
Dim char As Long
char = Selection.EndOf(Unit:=wdParagraph, Extend:=wdMove)
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Dim MyRange As Range
Set MyRange = ActiveDocument.Bookmarks("\Para"
ActiveDocument.Shapes.AddPicture FileName:="c:\test\" + Test$(I) + ".jpg" _
, LinkToFile:=False, SaveWithDocument:=True, Left:=36, Top:=200, Width:=288, Height:=169.2, Anchor:=MyRange
ActiveDocument.Shapes(1).Name = Test$(I)
Next
ActiveDocument.GoTo What:=wdGoToObject, Which:=wdGoToFirst, Name:="Shape"
With Selection.ShapeRange
.WrapFormat.Side = wdWrapLeft
.WrapFormat.DistanceTop = InchesToPoints(0)
.WrapFormat.DistanceBottom = InchesToPoints(0)
.WrapFormat.DistanceLeft = InchesToPoints(0.13)
.WrapFormat.DistanceRight = InchesToPoints(0.13)
.WrapFormat.Type = wdWrapTight
End With
For I = 1 To hms - 1
Selection.GoTo What:=wdGoToObject, Which:=wdGoToNext, Name:="Picture"
With Selection.ShapeRange
.WrapFormat.AllowOverlap = True
.WrapFormat.Side = wdWrapLeft
.WrapFormat.DistanceTop = InchesToPoints(0)
.WrapFormat.DistanceBottom = InchesToPoints(0)
.WrapFormat.DistanceLeft = InchesToPoints(0.13)
.WrapFormat.DistanceRight = InchesToPoints(0.13)
.WrapFormat.Type = wdWrapTight
End With
Next
'End Insert Pictures Section