Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Apr 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Changing Source File in Word (97)

    Edited by HansV to provide link to post - see <!help=19>Help 19<!/help>

    I have seen this question asked many times but have never found an answer that works for me.

    I have a word document that has links to information in an excel sheet. I need to create multiple copies of this document which all look at different versions of the excel sheet. Currently the only way to change the excel sheet that the word document looks at is to go into every link one by one and change the source file. Obviously this is time consuming with 100+ links. I am looking for a way to automate this with a macro.

    I want to be able to run the macro and have it change all of the link source files to any specified new source file.

    I found this post on the forum <post#=670027>post 670027</post#> which seems to offer a solution to what i need, but i cant get the macro to run properly, i have to remove the private part of the private sub Updated Fields so i can see the update fields macro. When i run it, it gives an error at the replace $ part.

    Any help would be appreciated.

    Thanks.

    Rich.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 18 Times in 18 Posts

    Re: Changing Source File in Word (97)

    Welcome to Woody's Lounge!

    If you display field codes (press Alt+F9), you can use Edit | Replace to replace the filename of the Excel workbook or worksheet - enter the old name in the Find what box and the new name in the Replace with box, then click Replace All. You can then hide field codes (press Alt+F9) and update all fields (Ctrl+A, F9).

    If you need to change the path to the workbook as well as the filename, you'll have to use two backslashes in the path instead of single backslashes .

  3. #3
    New Lounger
    Join Date
    Apr 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing Source File in Word (97)

    Thanks.

    I have put that into a macro so it changes fields as suggested.

    Currently i have to use an inputbox to insert the full file path i want to change it to. I would prefer to have this as a browse functionality however i cant work out how to change the inputbox into a browse box type thing.

    Thanks again

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 18 Times in 18 Posts

    Re: Changing Source File in Word (97)

    Unfortunately, Word 97 doesn't have a built-in general file open dialog.
    I have attached a zip file with three code modules (two standard modules and a class module) that you can import into the Visual Basic Editor using File | Import File...

    modGlobals and clsCommonDialog provide general code for an open dialog (and a save as dialog), and modExample contains a simple example of how to use it.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •