Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 06-13-2018, 10:31 PM
MANOHAR MANOHAR is offline Word Field Update Windows 7 32bit Word Field Update Office 2007
Advanced Beginner
Word Field Update
 
Join Date: Jan 2017
Posts: 33
MANOHAR is on a distinguished road
Default Word Field Update

How do we pragmatically find out that fields needs to be updated in the document before calling fields.Update()??



Thanks!
  #2  
Old 06-14-2018, 01:31 AM
Guessed's Avatar
Guessed Guessed is offline Word Field Update Windows 10 Word Field Update Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,966
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Interesting question. I have no idea.

The only way I think you could tell is by updating the field and then comparing the result with the previous value.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
  #3  
Old 06-14-2018, 02:03 AM
MANOHAR MANOHAR is offline Word Field Update Windows 7 32bit Word Field Update Office 2007
Advanced Beginner
Word Field Update
 
Join Date: Jan 2017
Posts: 33
MANOHAR is on a distinguished road
Default

Thanks! Could you tell me how can I programmatically compare the result?
  #4  
Old 06-14-2018, 03:24 AM
Guessed's Avatar
Guessed Guessed is offline Word Field Update Windows 10 Word Field Update Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,966
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Try this macro:
Code:
Sub FieldsUpdated()
  Dim aFld As Field, sBefore As String, sAfter As String
  Dim sMsg As String, iChangeCount As Integer
  For Each aFld In ActiveDocument.Fields
    sBefore = aFld.Result
    aFld.Update
    sAfter = aFld.Result
    If sBefore <> sAfter Then
      aFld.Result.HighlightColorIndex = wdDarkYellow
      iChangeCount = iChangeCount + 1
    End If
  Next aFld
  If iChangeCount > 0 Then
    MsgBox iChangeCount & " field(s) were changed. Look for the dark yellow highlights"
  Else
    MsgBox "No field changes"
  End If
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
  #5  
Old 06-14-2018, 05:40 AM
Charles Kenyon Charles Kenyon is offline Word Field Update Windows 10 Word Field Update Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,116
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Note, you probably want to run that on a copy of your document.
  #6  
Old 06-17-2018, 04:06 PM
Stefan Blom's Avatar
Stefan Blom Stefan Blom is offline Word Field Update Windows 10 Word Field Update Office 2016
Moderator
 
Join Date: Aug 2011
Posts: 3,900
Stefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to all
Default

Out of curiosity, why do you want to know if a field has been updated? It won't do any harm to update it whenever you want to ensure that the display is up to date (even if the field is already displaying the updated result).
__________________
Stefan Blom
Microsoft Word MVP

Microsoft 365 apps for business
Windows 11 Professional
  #7  
Old 06-17-2018, 07:18 PM
macropod's Avatar
macropod macropod is offline Word Field Update Windows 7 64bit Word Field Update Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Cross-posted (and answered before posting here) at: https://social.msdn.microsoft.com/Fo...?forum=worddev
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184

Manohar: This is the third time you've been asked in this forum to provide cross-post links. Consider this a final warning - cross-post again without providing links and your account will be terminated.

Thread closed.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Closed Thread

Tags
fields

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Update & Unlink Specific Merge Field in Word Doc from Mail Merge - Excel VBA RMerckling Mail Merge 16 05-17-2018 05:19 PM
Word Field Update Force Word (2007) to only update date field when asked to ShankedS Word 5 10-25-2016 06:45 AM
Word Field Update Can field dynamically update? namedujour Word 2 03-04-2016 10:21 PM
VBA script to update field codes? Calab Word VBA 1 04-07-2014 09:27 PM
Word Field Update Auto update Filename field Oliver Beirne Word VBA 4 10-19-2012 03:33 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:28 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft