- 12 Fev 2019 às 16:10
#41148
Olá malta,
Estou a criar uma folha e queria introduzir imagens nos cabeçalhos e rodapés mas usando VBA.
Encontrei este código que permite proteger o cabeçalho e rodapé mas queria inserir imagem em vez de texto em alguns deles.
Aqui fica o código. Podem ajudar-me a inserir as imagens também (mas usando esta proteção)?
Já tentei várias hipóteses mas… não consigo...
Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Call ProtectHF
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Call ProtectHF
End Sub
Private Sub Workbook_Open()
Call ProtectHF
End Sub
Private Sub ProtectHF()
'Updateby Extendoffice 20161027
Application.ScreenUpdating = False
Dim strHeaderTextL As String
strHeaderTextL = " Not for copy "
Dim strHeaderTextC As String
strHeaderTextC = " Created by ... "
Dim strHeaderTextR As String
strHeaderTextR = " Not for copy "
Dim strFooterTextL As String
strFooterTextL = " Not for copy "
Dim strFooterTextC As String
strFooterTextC = " Not for copy "
Dim strFooterTextR As String
strFooterTextR = " Not For Copy "
ThisWorkbook.ActiveSheet.PageSetup.RightHeader = "&B&20" & strHeaderTextR & ""
ThisWorkbook.ActiveSheet.PageSetup.RightFooter = "&B&20" & strFooterTextR & ""
ThisWorkbook.ActiveSheet.PageSetup.CenterHeader = "&B&20" & strHeaderTextC & ""
ThisWorkbook.ActiveSheet.PageSetup.CenterFooter = "&B&20" & strFooterTextC & ""
ThisWorkbook.ActiveSheet.PageSetup.LeftHeader = "&B&20" & strHeaderTextL & ""
ThisWorkbook.ActiveSheet.PageSetup.LeftFooter = "&B&20" & strFooterTextL & ""
Application.ScreenUpdating = True
End Sub
Estou a criar uma folha e queria introduzir imagens nos cabeçalhos e rodapés mas usando VBA.
Encontrei este código que permite proteger o cabeçalho e rodapé mas queria inserir imagem em vez de texto em alguns deles.
Aqui fica o código. Podem ajudar-me a inserir as imagens também (mas usando esta proteção)?
Já tentei várias hipóteses mas… não consigo...
Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Call ProtectHF
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Call ProtectHF
End Sub
Private Sub Workbook_Open()
Call ProtectHF
End Sub
Private Sub ProtectHF()
'Updateby Extendoffice 20161027
Application.ScreenUpdating = False
Dim strHeaderTextL As String
strHeaderTextL = " Not for copy "
Dim strHeaderTextC As String
strHeaderTextC = " Created by ... "
Dim strHeaderTextR As String
strHeaderTextR = " Not for copy "
Dim strFooterTextL As String
strFooterTextL = " Not for copy "
Dim strFooterTextC As String
strFooterTextC = " Not for copy "
Dim strFooterTextR As String
strFooterTextR = " Not For Copy "
ThisWorkbook.ActiveSheet.PageSetup.RightHeader = "&B&20" & strHeaderTextR & ""
ThisWorkbook.ActiveSheet.PageSetup.RightFooter = "&B&20" & strFooterTextR & ""
ThisWorkbook.ActiveSheet.PageSetup.CenterHeader = "&B&20" & strHeaderTextC & ""
ThisWorkbook.ActiveSheet.PageSetup.CenterFooter = "&B&20" & strFooterTextC & ""
ThisWorkbook.ActiveSheet.PageSetup.LeftHeader = "&B&20" & strHeaderTextL & ""
ThisWorkbook.ActiveSheet.PageSetup.LeftFooter = "&B&20" & strFooterTextL & ""
Application.ScreenUpdating = True
End Sub