![]() |
#2
|
||||
|
||||
![]()
It's not clear what you mean by 'not working', but one problem you'll have is that the 'refreshFields2' sub closes the active document, leaving wdDoc in the UpdateDocuments sub undefined.
In any event, you should be able to achieve the same result with: Code:
Sub UpdateDocuments() Application.ScreenUpdating = False Dim strDocNm As String, strFolder As String, strFile As String, wdDoc As Document strFolder = GetFolder If strFolder = "" Then Exit Sub strFile = Dir(strFolder & "\*.doc", vbNormal) strDocNm = ThisDocument.FullName While strFile <> "" If strFolder & "\" & strFile <> strDocNm Then Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False) With wdDoc .Fields.Update .PrintPreview .ClosePrintPreview .Close SaveChanges:=True End With End If strFile = Dir() Wend Set wdDoc = Nothing Application.ScreenUpdating = True End Sub Function GetFolder() As String Dim oFolder As Object GetFolder = "" Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0) If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path Set oFolder = Nothing End Function
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to update calculated fields | sectionbreak | Mail Merge | 4 | 06-04-2014 12:12 AM |
Office 2010 Can't Open Or Save Documents in My Documents Folder | trippb | Office | 1 | 07-12-2013 07:29 AM |
![]() |
PeaceDove | Word | 3 | 01-17-2012 02:45 PM |
VBA to update certain (but not all) fields | sparkyrose | Word VBA | 0 | 05-20-2010 12:50 PM |
Can no longer update fields! | slindsay | Word | 0 | 09-03-2009 05:10 PM |