Solved

Word VBA: Update All Fields but not linked spreadsheets

Posted on 2014-10-10
4
259 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
  • 2
4 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
Comment Utility
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
Comment Utility
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:EricFletcher
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…

772 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now