?
Solved

Word VBA: Update All Fields but not linked spreadsheets

Posted on 2014-10-10
4
Medium Priority
?
298 Views
Last Modified: 2014-11-02
Hi experts

I have the following code to update all fields in the document, The only problem is that it is also wanting to update all linked fields example linked spreadsheets, so you end up having say "yes/no" to update all these linked files, which is just annoying. I'm wanting to update stylerefs fields, captions, SEQ fields, cross references, etc, not linked files.

Is there a way to stop the requests to update the linked files?,
 
Sub MyUpdateFields()
   
    ActiveDocument.Fields.Update
       
End Sub

Open in new window

0
Comment
Question by:Fi69
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 40374273
I can't actually produce that symptom. If I could do so, I would be able to test this code:
Sub MyUpdateFields()
    Application.DisplayAlerts = False
    ActiveDocument.Fields.Update
    Application.DisplayAlerts = True
End Sub

Open in new window

If that doesn't help, you could try this macro:
Sub MyUpdateFields()
    Dim fld As Field
    
    For Each fld In ActiveDocument.Fields
        If fld.Type <> wdFieldLink Then
            fld.Update
        End If
    Next fld
End Sub

Open in new window

0
 

Author Comment

by:Fi69
ID: 40374352
Thanks Graham
I can't get it to happen at this end either. Let me check those methods with my user on Monday and I'll respond then which method works.
0
 
LVL 21

Expert Comment

by:Eric Fletcher
ID: 40390721
Do your LINK field codes include the \a switch? This switch is typically the default, and causes the links to be updated automatically; without it, they need to be updated manually.

In a quick test using Ctrl-A and F9 as a manual equivalent to your code to update all such fields, I didn't get any confirm prompts for a mix of LINK fields with and without the \a switch -- but perhaps the interface is different when it is being run from the VBA code.
0
 

Author Comment

by:Fi69
ID: 40418668
Hi, thanks Eric for the tip on the \a switch. Hard to control that though. Graham, looping through the fields has fixed the issue - don't know if it is going to be slow in large document, but I've reduced the number of times I'm updating fields, so should be bearable. Thank you.

Sub MyUpdateFields()
    Dim fld As Field
   
    For Each fld In ActiveDocument.Fields
        If fld.Type <> wdFieldLink Then
            fld.Update
        End If
    Next fld
End Sub
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question