I am using Excel to write up a report in which multiple sheets are selected and then printed. I wrote some visual basic commands to insert a left footer with a date/client code, center footer with a picture, and right footer with a page number. Everything works great with the exception of the command to crop the bottom of the footer, it only crops the footer on the last sheet in the group that you selected (active window). I do not understand why it inserts the picture in all of them, but only crops the active window when both commands are in the same spot. Can you look at this code and tell me what you see that might be causing this issue:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim ws As Worksheet
For Each ws In ActiveWindow.SelectedSheets
With ws.PageSetup.CenterFooterPicture
.Filename = "M:\Location on server\mypicture.jpg"
.CropBottom = 5
End With
ws.PageSetup.FooterMargin = 28.8
ws.PageSetup.LeftFooter = "&""Georgia""&11&i" & Format(Sheets("input").Range("E7"), "mmmm d, yyyy") & " (" & Sheets("input").Range("C7") & ")"
ws.PageSetup.CenterFooter = "&G"
ws.PageSetup.RightFooter = "&""Georgia""&11&i" & "Page &P"
Next ws
End Sub
Bookmarks