Hi knigget,
In both cases, it's the file(s) your Word document is linked to (eg an Excel workbook containing the data).
Hi knigget,
In both cases, it's the file(s) your Word document is linked to (eg an Excel workbook containing the data).
Cheers,
Paul Edstein
[MS MVP - Word]
I tried this macro but got the following error: "Run-time error '91': Object variable or With block variable not set". When I clicked on Debug, it sent me to this line in the macro code: OldPath = GetPath(.LinkFormat.SourceFullName). Any suggestions?
I tried this macro but got the following error: "Run-time error '91': Object variable or With block variable not set". When I clicked on Debug, it sent me to this line in the macro code: OldPath = GetPath(.LinkFormat.SourceFullName). Any suggestions?
Last edited by macropod; 2012-06-22 at 18:48. Reason: Deleted uncecessary quote of entire early post
Without knowing what field it's throwing the error on, the only thing I can think of is that you have a hyperlink in the document that only points to another location within the same document. Do you have such hyperlinks?
Cheers,
Paul Edstein
[MS MVP - Word]
For links to bookmarks within the same document, one would ordinarily use cross-references, not hyperlinks.
You could try inserting:
On Error Resume Next
before:
If .Type = wdFieldHyperlink Or .Type = wdFieldImport _
Cheers,
Paul Edstein
[MS MVP - Word]
I have Word 2010. So far, this seems to work for me.
My explanation is a bit lengthy. Understanding my folder structure will help you understand the field code.
Example Project Structure
10100824_Project folder is the top-level folder.
The 10100824_Project folder has individual Word files for publication 10100824; there is one Word file per chapter.
Inside the 10100824_Project folder is a sub-folder named 10100824_Pictures.
The 10100824_Pictures sub-folder has PNG files of screen captures of entire software screens.
Inside the 10100824_Pictures sub-folder is another sub-folder named Button_Images.
The Button_Images sub-folder contains PNG files of screen captures of individual software control buttons.
Your task: You want to link graphics by reference into a Word file.
Here is the field code to create a relative link that displays a PNG file of a screen capture of an entire software screen:
{INCLUDEPICTURE 10100824_Pictures/10100824_XXXX.PNG}
Where:
- INCLUDEPICTURE is the Word field code.
- 10100824_Pictures is the name of the folder that contains PNG files of screen captures of entire software screens.
- 10100824_XXXX is the file name of the PNG with the software screen that you want to display in the Word document.
Here is the field code to create a relative link that displays a PNG file of a software control button:
{INCLUDEPICTURE 10100824_Pictures/Button_Images/ZZZZ_ZZZZ_.png}
Where:
- INCLUDEPICTURE is the Word field code.
- 10100824_Pictures is the name of the folder that contains a folder named Button_Images.
- The Button_Images folder contains PNG files with images of software control buttons.
- ZZZZ_ZZZZ.png is the file name of the PNG file with the image of the software control button that you want to display in the Word document.
Hi jfmiller,
That approach works with the docx format only, in Word 2007 & later.
Cheers,
Paul Edstein
[MS MVP - Word]
Hi
I have a problem that may have been addressed here but am looking to create a template word document linked to an excel worksheet to contain loads of jobsite information and service criteria to populate the word report. The idea was to create the template with its worksheet in a folder and then copy the entire folder and rename it to the different job folders we have.
Using word and excel 2007 when we copy the folder to a new location the links in the word document still go back to the original excel file in the original folder.
I have tried changing the 'Link' by using alt f9 and changing the text but it doesn't seem to accept the change in folder name for the file location.
Any help would be greatly appreciated.
Many thanks
Chris
I am using Word 2010.
I am saving my Word files as a "Word 97-2003 Document (*.doc)".
So far this works for me, but with Word one never knows.
Hi jfmiller,
The whole point of this thread is that the approach you outlined is not reliable with Word 2003 & earlier - or doc files in general.
Cheers,
Paul Edstein
[MS MVP - Word]
Hi Chris,
Changing the file & folder names should work. In fact, changing the folder name is what the macro in http://windowssecrets.com/forums/sho...l=1#post584769 does.
Cheers,
Paul Edstein
[MS MVP - Word]
Hi Paul
I have tried putting this macro back in and changing the file paths again and they revert back to original when i re open the document.
Maybe i am expecting too much, i am trying to create numerous word documents each tied to its own dedicated spreadsheet and then move them as pairs to each jobfile, would i be better to embed the entire spreadsheet in the word document and then could i copy anywhere?
Thanks
Chris
If you are using the macro as intended, the filepaths in the fields will change when the actual paths change; otherwise, I'd expect to see the original paths.
Cheers,
Paul Edstein
[MS MVP - Word]
Hi Paul
Unfortunately i am trying to achieve the opposite effect in some ways. I am trying to create a word doc that has a number of tables controlled by an excel sheet and then clone the combination to make multiple versions i can then paste certain components into to make site specific. Is there a simple way of doing this?