![]() |
#2
|
||||
|
||||
![]()
Try:
Code:
Sub UpdateDocumentHeaders() Application.ScreenUpdating = False Dim strFolder As String, strFile As String, StrTxt As String Dim wdDocTgt As Document, wdDocSrc As Document strFolder = GetFolder If strFolder = "" Then Exit Sub StrTxt = InputBox("Text to add to headers? e.g. ""March 1, 2018""") If Trim(StrTxt) = "" Then Exit Sub Set wdDocSrc = ActiveDocument strFile = Dir(strFolder & "\*.doc", vbNormal) While strFile <> "" If strFolder & "\" & strFile <> wdDocSrc.FullName Then Set wdDocTgt = Documents.Open(FileName:=strFolder & "\" & strFile, _ AddToRecentFiles:=False, Visible:=False) With wdDocTgt .Sections(1).Headers(wdHeaderFooterPrimary).Range.InsertAfter StrTxt .Close SaveChanges:=True End With End If strFile = Dir() Wend Set wdDocSrc = Nothing: Set wdDocTgt = 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 |
Word 2016 Multi-file Macro issues | IneedHelpWithWord | Word VBA | 1 | 08-08-2017 09:29 PM |
![]() |
DrDress | Word | 4 | 04-17-2017 06:39 PM |
![]() |
aaronbauer1980 | Excel Programming | 1 | 04-15-2016 05:53 PM |
![]() |
BriMan83 | Mail Merge | 1 | 04-24-2013 11:35 PM |
![]() |
Evgeniy | Word | 1 | 02-04-2012 01:36 PM |