Solved

Word VBA: Update All Fields but not linked spreadsheets

Posted on 2014-10-10
4
269 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
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:EricFletcher
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
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…
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…
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

821 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