Word '03 Field Codes / INCLUDEPICTURE / Directory Changes...
Hi all,
Does anybody have a good resource for MS Word field codes, or a solution to this ...
I'm trying to use INCLUDEPICTURE, but I want to use dynamic paths. For example, if I'm working on C:\Docs\Doc1.doc with an INCLUDEPICTURE to C:\Docs\Pics\Pic1.jpg and I save my doc to D:\WorkingFolder\ my INCLUDEPICTURE is still linked to C:\Docs\Pics instead of D:\WorkingFolder\Pics.
Is there a way to force the INCLUDEPICTURE to automatically get my active doc's path (and change it when saved in an alterate place) and base its image path on said active doc's path?
Thx
Re: Word '03 Field Codes / INCLUDEPICTURE / Directory Changes...
on testing with word 2000 i find this is the default behavior with includepicture, even if no path is specified, it remeber the original source path, but you can set the path like this
vb Code:
Dim d As Document, f As Field
Set d = ActiveDocument
Set f = d.Fields.Add(Range:=Selection.Range, Type:=wdFieldEmpty, Text:="INCLUDEPICTURE ""image1.jpg""", PreserveFormatting:=True)
f.LinkFormat.SourceFullName = "C:\Documents and Settings\peter\My Documents\image1.jpg"
Re: Word '03 Field Codes / INCLUDEPICTURE / Directory Changes...
Thanks.
What is the sourcefullname part doing? Is that always reverting back to that Docs&Settings folder, or does it make the path dynamic [based on where the activedoc is]?
Also, how would I "trigger" this? I'm going to have a dozen bookmarks, with a dozen includepictures. I can put the above in Document_Open, but how does it set the path for (and fire) the individual includes?
Re: Word '03 Field Codes / INCLUDEPICTURE / Directory Changes...
sourcefullname hardcodes the path to the picture, no matter where the doument is,
how you trigger is up to you, maybe on document close you can loop through all the fields in the document, check (if sourcefullname = sourcename), does not include a path you can set it them, then save, or add a button to the command toolbar
Re: Word '03 Field Codes / INCLUDEPICTURE / Directory Changes...
Could I not set docpath = ActiveDocument.Path and then use that docpath somewhere?
Sorry for my newbieness. I know "enough to be dangerous," but I'm still learning the ins, outs, and pitfalls of everything.
I'm thinking that, on open or with a macro, it can look for the path (or I can supply the path through a get path input/search box), and it can "find/replace" my activedoc's path for some innoucuous placeholder. For example, the template has { INCLUDEPICTURE "FINDREPLACEPATH" & "streetview.jpg" }
The macro would 1) get the path from the activedoc (wherever it is...) 2) Find/Replace FINDREPLACEPATH for the activedoc path 3) the end.