dcsimg
Results 1 to 2 of 2

Thread: Word linked Excel files, change path (not filename iteself)

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2018
    Posts
    1

    Question Word linked Excel files, change path (not filename iteself)

    Hello,

    In MS Word, linked files have absolute address, so I want to write macro which changes Excel links relatively to the place where my .docm file is. (e.g. I copy a project for another customer to a new directory, both exist)

    When I use command
    "ActiveDocument......LinkFormat.SourceFullName = NewFileNameWithPath", I get "sorry, excel cant open two workboos with the same name at the same time" error.

    The thing is, that even when Excel is closed, it opens when that command occurs. I don't understand why. It seems like Excel wants to open both files that have same name, but different path. It is stupid behaviour. I just want to change one string in MS Word file and Excel is unexpectedly opening (btw. you'll see it only in task manager, not showing any window).

    Well I found workaroud, programatically change the path manually in MS Word file since this file is zipped xml, of course when you don't use old .doc file.

    Any other idea?

    Thanks

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Java (JSP) Hell!
    Posts
    5,294

    Re: Word linked Excel files, change path (not filename iteself)

    If word is displaying the excel, then it opens it to get the data. As it is probably using an excel application, it will try to use that (same as windows... if one is open it will try to use the last one opened - even if you hid it from view).

    Since it is erroring with that, the logical thing would be to close the link first then rename it to the new location then re-open it.
    I have not used automation like this with word already linking. So cannot advise how to close the link. Maybe intellisense will give you some ideas?

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width