when printing a sheet, I have the code below (example) which puts a logo in the left header section of my printout.
The logo is stored on a path in C:
Now, when this path changes, or when the logo would not exist, I want NO LOGO to be printed.
However, it remains being printed. Can anyone solve ?
The logo is stored on a path in C:
Now, when this path changes, or when the logo would not exist, I want NO LOGO to be printed.
However, it remains being printed. Can anyone solve ?
VBA Code:
Sub AddFooterHeaderImage()
Dim sht As Worksheet
Dim ImagePath As String
Dim Validation As String
'Where is Image Located?
ImagePath = "C:\Users\bob\Documents\Company Logo.png"
'Does the Image File Exist?
On Error Resume Next
Validation = Dir(ImagePath)
On Error GoTo 0
If Validation = "" Then
MsgBox "Could not locate the image file located here: " & ImagePath
Exit Sub
End If
'Add Image To Each Active Sheet
For Each sht In ActiveWorkbook.Windows(1).SelectedSheets
'Insert Image (ie "LeftFooter","CenterFooter","RightFooter", _
"LeftHeader","CenterHeader","RightHeader")
sht.PageSetup.LeftFooter = "&G"
sht.PageSetup.LeftFooterPicture.Filename = ImagePath
'Ensure Pagebreaks don't show (they are annoying!)
sht.DisplayPageBreaks = False
Next sht
End Sub