Solved

Word VBA: Update All Fields but not linked spreadsheets

Posted on 2014-10-10
4
278 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 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The Selection object is designed for user interaction. It has a Range property, so it can be used in most places that a Range object can. Recorded macros must use the Selection because they are simply copying what the user is doing. A Range prope…
Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

742 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