Monk3
12-19-2010, 03:46 PM
Hi I needed to do a batch image change in the header for 648 docx files. I got this code from this site and it worked great! Trouble is that it is aligning the header image centered when I need it right aligned. Can any one help with this... should be easy but after a lot of looking I can't find it and my coding days are long long gone. Here is the code:
Sub ReplaceEntireHdr()
Dim wrd As Word.Application
Set wrd = CreateObject("word.application")
wrd.Visible = True
AppActivate wrd.Name
'Change the directory to YOUR folder's path
FName = Dir("h:\Temp\*.docx")
Do While (FName <> "")
With wrd
'Change the directory to YOUR folder's path
.Documents.Open ("H:\Temp\" & FName)
If .ActiveWindow.View.SplitSpecial = wdPaneNone Then
.ActiveWindow.ActivePane.View.Type = wdPrintView
Else
.ActiveWindow.View.Type = wdPrintView
End If
.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
.Selection.WholeStory
.Selection.Paste
.ActiveDocument.Save
.ActiveDocument.Close
End With
FName = Dir
Loop
Set wrd = Nothing
End Sub
Thanks for any help!
Sub ReplaceEntireHdr()
Dim wrd As Word.Application
Set wrd = CreateObject("word.application")
wrd.Visible = True
AppActivate wrd.Name
'Change the directory to YOUR folder's path
FName = Dir("h:\Temp\*.docx")
Do While (FName <> "")
With wrd
'Change the directory to YOUR folder's path
.Documents.Open ("H:\Temp\" & FName)
If .ActiveWindow.View.SplitSpecial = wdPaneNone Then
.ActiveWindow.ActivePane.View.Type = wdPrintView
Else
.ActiveWindow.View.Type = wdPrintView
End If
.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
.Selection.WholeStory
.Selection.Paste
.ActiveDocument.Save
.ActiveDocument.Close
End With
FName = Dir
Loop
Set wrd = Nothing
End Sub
Thanks for any help!