I am using vb6 with word 97 or 2000 (user's choice)
My software needs to replace a text placeholder in a Word document with a
picture from a .jpg file and, of course, should work for all reasonable
versions of Word.
Ideally, for page layout convenience, the placeholder ("#PICTUREHERE#") is
in a Table (1 row, 1 column).
The subroutine below works fine with Word 2000 but, in Word 97 the picture
finishes outside the table (before it) even if I put a space before the
placeholder. I have tried putting the picture in the Clipboard and
Selection.Paste with the same result in Word 97.
Is there any way I can ensure that Word 97 puts a picture into a Table?
The essence of my MergePic Subroutine is as follows.
Sub MergePic(Appw As Object, picfilename$, PlaceHolder As String)
' Appw is a Word Object,
' PlaceHolder is something like "#PLACEHOLDER#"
' picfilename$ is a .jpg file normally
.Find.Text = PlaceHolder
.Find.Replacement.Text = ""
.Find.Forward = True
.Find.Wrap = wdFindContinue
.Find.Format = False
.Find.MatchCase = False
.Find.MatchWholeWord = False
.Find.MatchWildcards = False
.Find.MatchSoundsLike = False
.Find.MatchAllWordForms = False
Do While Appw.Selection.Find.Found
'replace text with blank
Appw.ActiveDocument.Shapes.AddPicture Anchor:=Appw.Selection.Range, _
FileName:=picfilename$, LinkToFile:=False, SaveWithDocument:=True
Appw.Selection.TypeText Text:=" "
I would greatly appreciate help from somewhere