|
-
Jun 21st, 2008, 08:09 PM
#1
Thread Starter
Member
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
Last edited by Hoop; Jun 21st, 2008 at 08:56 PM.
-
Jun 22nd, 2008, 03:05 AM
#2
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"
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jun 23rd, 2008, 08:30 AM
#3
Thread Starter
Member
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?
Last edited by Hoop; Jun 23rd, 2008 at 08:44 AM.
-
Jun 23rd, 2008, 04:55 PM
#4
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jun 24th, 2008, 08:53 AM
#5
Thread Starter
Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|