Solved

Word VBA: Update All Fields but not linked spreadsheets

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

729 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