Results 1 to 8 of 8
  1. #1
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBA - Word2K, Change source on linked picture (Env: W2K, O2K both Pro, UK

    Hi,

    In multiple documents, I have a large number of linked pictures that I need to automatically change paths on (approx. 70 in each file).

    In Word, I would normally for a few number of pictures manually use "Edit/links/change source"
    But in VBA for "fields" and "linkformat", I cannot find a "change source" method.

    How can I then change the paths for these files ??


    Thanks,
    ;O)) Henrik
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

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

    Re: VBA - Word2K, Change source on linked picture (Env: W2K, O2K both Pro,

    Take a look at macropod's Star Post <post#=261488>post 261488</post#>

  4. #3
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA - Word2K, Change source on linked picture (Env: W2K, O2K both Pro,

    Thanks Hans,

    ....but finding heads and tales of that discussion is a bit confusing - not being a part of it...

    Meanwhile I received a really useful tip from a Word MVP


    'By Doug Robbins - to update links in a document
    Dim alink As Field, linktype As Range, linkfile As Range
    Dim linklocation As Range, i As Integer, j As Integer, linkcode As Range
    Dim Message, Title, Default, Newfile
    Dim counter As Integer

    counter = 0
    For Each alink In ActiveDocument.Fields
    If alink.Type = wdFieldLink Then
    Set linkcode = alink.Code
    i = InStr(linkcode, Chr(34))
    Set linktype = alink.Code
    linktype.End = linktype.Start + i
    j = InStr(Mid(linkcode, i + 1), Chr(34))
    Set linklocation = alink.Code
    linklocation.Start = linklocation.Start + i + j - 1
    If counter = 0 Then
    Set linkfile = alink.Code
    linkfile.End = linkfile.Start + i + j - 1
    linkfile.Start = linkfile.Start + i
    Message = "Enter the modified path and filename following this
    Format " & linkfile
    Title = "Update Link"
    Default = linkfile
    Newfile = InputBox(Message, Title, Default)
    End If
    linkcode.Text = linktype & Newfile & linklocation
    counter = counter + 1
    End If
    Next alink


    Bests,
    Henrik
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

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

    Re: VBA - Word2K, Change source on linked picture (Env: W2K, O2K both Pro,

    I'm glad that you found a solution. I notice that you have to specify a path and file name for each link field in the document individually. If that suits your purpose, fine. It gets cumbersome, though, if you only moved the files from one folder to a different folder. Macropod's macro in the attachment to <post#=261488>post 261488</post#> lets you specify a path once, then substitutes this in all link fields.

  6. #5
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,767
    Thanks
    0
    Thanked 162 Times in 150 Posts

    Re: VBA - Word2K, Change source on linked picture (Env: W2K, O2K both Pro,

    Hi Henrik,

    Re:
    <hr>....but finding heads and tales of that discussion is a bit confusing - not being a part of it...<hr>
    I've now added a synopsis to help make things clearer. With a task the size of your's, I think I'd prefer not to be asked for every source file's name and path - though my solution doesn't deal with source files that are in multiple folders.

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  7. #6
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA - Word2K, Change source on linked picture (Env: W2K, O2K both Pro,

    Hi M-pod

    Thanks for the synopsis.

    You're absolutely right, about this getting tedious.
    My problem is that it's a many-to-many (some 20 folders and approx. 140 files)
    (I've done a select case to map folders appropiately)

    What I forgot to mention in my answer to your discussion was that specifically the messagebox bit I had taken out and modified the code accordingly.

    My mistake, apologies.

    Bests,
    Henrik

    PS: Any idea or news as to when the disabled search function becomes available again (I'm taking that it will be....??)
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  8. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 15 Times in 15 Posts

    Re: VBA - Word2K, Change source on linked picture (Env: W2K, O2K both Pro,

    >> PS: Any idea or news as to when the disabled search function becomes available again (I'm taking that it will be....??)

    Unfortunately, we don't know. <img src=/S/claude.gif border=0 alt=claude width=21 height=21> (Claude) has to do everything in his spare time, and he hardly has any the moment. If there are new developments, they will be announced in the Newsflash.

  9. #8
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,767
    Thanks
    0
    Thanked 162 Times in 150 Posts

    Re: VBA - Word2K, Change source on linked picture (Env: W2K, O2K both Pro,

    Hi there Henrik,

    You might want to check out the updated <post#=261488>post 261488</post#> - the new version of the field link updater provides much more flexibility and caters for the many-to-many relationships you're working with.

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Posting Permissions

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