Propósito

✔ Programação GLOBAL® - Quaisquer soluções e/ou desenvolvimento de aplicações pessoais, ou da empresa, que não constem neste Blog devem ser tratados como consultoria freelance. Queiram contatar-nos: brazilsalesforceeffectiveness@gmail.com | ESTE BLOG NÃO SE RESPONSABILIZA POR QUAISQUER DANOS PROVENIENTES DO USO DOS CÓDIGOS AQUI POSTADOS EM APLICAÇÕES PESSOAIS OU DE TERCEIROS.

.: Vitrine

Carregando artigos...

Views

Mostrando postagens com marcador cabeçalho. Mostrar todas as postagens
Mostrando postagens com marcador cabeçalho. Mostrar todas as postagens

VBA Excel - Inserindo Cabeçalhos e Rodapés - Insert headers and footers using VBA


Já pensou a respeito de como pode ser útil colocarmos cabeçalhos e rodapés personalizados nas planilhas que entregamos para os nossos chefes, departamentos clientes, ou mesmo em Dashboards, Scorecards, e Gráficos que enviamos por e-mail.

Seria ainda melhor se pudéssemos automatizar a colocação destes com contadores de página, data e horário, logomarca da empresa e em alguns casos com títulos e enunciados analíticos que reflitam o conteúdo daquilo que está sendo entregue.

  Sub InsHeadFoot()
' Insira o mesmo cabeçalho/rodapé em todas as abas
Dim ws As Worksheet
      Let Application.ScreenUpdating = False

    For Each ws In ActiveWorkbook.Worksheets
          Let Application.StatusBar = "Alterando Cabeçalho/Rodapé em " & ws.Name
        With ws.PageSetup
              Let .LeftHeader = "Nome da Compania"
              Let .CenterHeader = "Pág. &P de &N"
              Let .RightHeader = "Impresso em &D &T"
              Let .LeftFooter = "Path : " & ActiveWorkbook.Path
            Let .CenterFooter = "Nome da planilha &F"
            Let .RightFooter = "Aba &A"
        End With
      Next ws

      Set ws = Nothing

      Let Application.StatusBar = False
End Sub

  Tags: Excel, VBA, header, footer, cabeçalho, rodapé, 
  


VBA Word - Inserindo cabeçalho e rodapé no documento - Word Footer and Header Code

Inline image 1

| 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? 

Tente utilizar o código abaixo:

Sub PutHeader_Footer()
 If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
 ActiveWindow.Panes(2).Close
 End If

 If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
 ActivePane.View.Type = wdOutlineView Then
 Let ActiveWindow.ActivePane.View.Type = wdPrintView
 End If

 Let ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
 Let Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
 Let Selection.TypeText Text:="BERNARDES - Aqui está o cabeçalho! "

 Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldDate
 Selection.TypeText Text:=" "
 Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldTime
 Selection.Find.ClearFormatting

 If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
 ActivePane.View.Type = wdOutlineView Then
 Let ActiveWindow.ActivePane.View.Type = wdPrintView
 End If

 Let ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter

 NormalTemplate.AutoTextEntries("Digite o nome do arquivo com o respectivo path").Insert Where:= _
 Selection.Range, RichText:=True
 Selection.TypeText Text:=" "
 NormalTemplate.AutoTextEntries("Criado em").Insert Where:=Selection.Range _
 , RichText:=True
 Selection.TypeText Text:=" "
 NormalTemplate.AutoTextEntries("- Pág. ").Insert Where:=Selection.Range, _
 RichText:=True
 ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub 


Tags: VBA, Word, footer, header, code, cabeçalho, rodapé, inserir



diHITT - Notícias