+ Reply to Thread
Results 1 to 1 of 1

Coding only crops footer picture in active window

Hybrid View

  1. #1
    Registered User
    Join Date
    01-07-2010
    Location
    Indiana, USA
    MS-Off Ver
    Excel 2007
    Posts
    24

    Coding only crops footer picture in active window

    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
    Last edited by ben98gs; 02-25-2011 at 11:33 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1