| Blog Office VBA | Blog Excel | Blog Access |
Como posso automatizar a inserção de um cabeçalho e um rodapé no meu documento do MS Word?
Como posso automatizar a inserção de um cabeçalho e um rodapé no meu documento do MS Word?
Tente utilizar o código abaixo:
Sub PutHeader_Footer()
If ActiveWindow.View.SplitSpecial <> wdPaneNone ThenActiveWindow.Panes(2).CloseEnd IfIf ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _ActivePane.View.Type = wdOutlineView ThenLet ActiveWindow.ActivePane.View.Type = wdPrintViewEnd IfLet ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeaderLet Selection.ParagraphFormat.Alignment = wdAlignParagraphCenterLet Selection.TypeText Text:="BERNARDES - Aqui está o cabeçalho! "Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldDateSelection.TypeText Text:=" "Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldTimeSelection.Find.ClearFormatting
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _ActivePane.View.Type = wdOutlineView ThenLet ActiveWindow.ActivePane.View.Type = wdPrintViewEnd If
Let ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooterNormalTemplate.AutoTextEntries("Digite o nome do arquivo com o respectivo path").Insert Where:= _Selection.Range, RichText:=TrueSelection.TypeText Text:=" "NormalTemplate.AutoTextEntries("Criado em").Insert Where:=Selection.Range _, RichText:=TrueSelection.TypeText Text:=" "NormalTemplate.AutoTextEntries("- Pág. ").Insert Where:=Selection.Range, _RichText:=TrueActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
Nenhum comentário:
Postar um comentário