Hi -
I have a number of Word documents that contain delimited text strings
with the path and filename of a picture. For example:

<#c:\temp\picture1.jpg#>

I'd like to search the document, find the picture references (based on
the <#...#>) and replace the text with the picture.

Before I open my first VBA book could someone let me know if this is
worth looking into doing? If so, a little push in the right direction
would be greatly appreciated!

Thanks-
Pete

Re: Replacing "tag" with a picture by Doug

Doug
Thu Jul 08 17:48:30 CDT 2004

Hi Pete,

It's quite possible to do with VBA. Something like the following should do
it, but first, use Edit>Replace to replace each \ with \\.

Dim tag As Range, fname As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="\<#*#\>", MatchWildcards:=True,
Wrap:=wdFindContinue, Forward:=True) = True
Set tag = Selection.Range
Set fname = Selection.Range.Duplicate
fname.End = fname.End - 2
fname.Start = fname.Start + 2
ActiveDocument.Fields.Add Range:=tag, Type:=wdFieldEmpty,
Text:="IncludePicture " & fname
Loop
End With

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
"Pete Lund" <pete.lund@lgan.com> wrote in message
news:Xns95204BBF2F59Epetelundlgancom@216.196.105.130...
> Hi -
> I have a number of Word documents that contain delimited text strings
> with the path and filename of a picture. For example:
>
> <#c:\temp\picture1.jpg#>
>
> I'd like to search the document, find the picture references (based on
> the <#...#>) and replace the text with the picture.
>
> Before I open my first VBA book could someone let me know if this is
> worth looking into doing? If so, a little push in the right direction
> would be greatly appreciated!
>
> Thanks-
> Pete