Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Word Saving Invalid Link Path

Status
Not open for further replies.

GCRanger

MIS
Aug 6, 2003
5
US
hi all,
I did a search but couldn't find anything for the particular issue I am having.

I have a Word 2003 template which creates relative links in a base Word document to other documents that will be located in the same directory. It does this by gathering a list of links (signified by a specific font color and text combination (ie. purple and 'GP 99-99-99').

1. Moves base document from base path to working path so that it is not disturbed while editing is going on
Base Path: Z:\NewPublish\1Publish\GP000000_com.doc
Working Path: Z:\NewPublish\1Publish\working\GP000000_com.doc

2. Opens document and finds text 'GP 99-99-99' to be turned in to a link ().
3. Creates link with code: ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:=sDocName, SubAddress:=""
where sDocName = GP999999.doc

When stepping through the code I can see that the links are created properly by manually editing the link and by using Alt-F9....{ HYPERLINK "GP999999.doc" }

5. Saves a temp file in path: Z:\NewPublish\1Publish\tempword8.doc
6. Copies temp file to : Z:\NewPublish\4Web\GP000000.doc

When I open the GP000000.doc document in it's destination folder and edit the hyperlink the link is now "working/GP999999.doc", but displays as { HYPERLINK "GP999999.doc" } when using Alt-F9. The path no longer works!

I can't for the life of me figure out where or why the working/ is being added to the link. I imagine it's some kid of setting in Word 2003. I didn't have this issue in Word 97 (no changes were made to the template code when upgrading to Word 03).

Please help.

Thanks
 
Can you make Address:=sDocName the full path and filename of what it WILL be? Rather than just using the doc name. Word will use the doc name, for sure, but it will pick up the existing path. In which case, of course, the current path at the time you make the instruction IS "working". Make the string variable the full path and doc name.

When you did the checking, stepping through, it will not show the full path with Alt-F9 as the path is the same as the current doc. It WILL show the full path if you actually edit the hyperlink.

Gerry
 
Gerry,

Unfortunatley the way our system is set up we cannot use an exact path. These files (base docs and linked docs) are downloaded by users from a web site and saved anywhere, hence the need to just use the filename. If we used full paths then the users would have to change the links if they saved it the files to another location.

I addedd the SDocName variable to the watch while debugging and it equals the filename without the 'working\'path when the code runs. So I'm still not sure why Word automatically adds the current path, 'working', when the doc is saved. Is this a setting in Word 2003? It did not do this in our previous version of Word.
 
I figured it out. It's a simple Options issue.
In word, go to Tools > Options > General tab > Web Options button, Files tab. Uncheck 'Update links on save'. Click OK then OK again.

I suppose this default setting changed from W97 to W2003.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top