Macro Problem with Logo in Header

ldhawan

New Member
Joined
Jun 20, 2016
Messages
14
Hi guys,
I'm having difficulty inserting a logo in my Header using a macro.
I've pasted the code below:
Code:
Sub Logo()
'
' Logo Macro
'
' Keyboard Shortcut: Ctrl+Shift+B
'
    ActiveWindow.View = xlPageLayoutView
    ActiveSheet.PageSetup.CenterHeaderPicture.Filename = _
        "C:\Users\NEW\Documents\Absolute Solutions\Checkpoint\Admin\LOGOS\Absolute Logo Macro.png"
    Application.PrintCommunication = False
    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = "&G"
        .RightHeader = "&P"
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.7)
        .RightMargin = Application.InchesToPoints(0.7)
        .TopMargin = Application.InchesToPoints(0.75)
        .BottomMargin = Application.InchesToPoints(0.75)
        .HeaderMargin = Application.InchesToPoints(0.3)
        .FooterMargin = Application.InchesToPoints(0.3)
        .Zoom = 100
        .PrintErrors = xlPrintErrorsDisplayed
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = False
        .ScaleWithDocHeaderFooter = True
        .AlignMarginsHeaderFooter = True
        .EvenPage.LeftHeader.Text = ""
        .EvenPage.CenterHeader.Text = ""
        .EvenPage.RightHeader.Text = ""
        .EvenPage.LeftFooter.Text = ""
        .EvenPage.CenterFooter.Text = ""
        .EvenPage.RightFooter.Text = ""
        .FirstPage.LeftHeader.Text = ""
        .FirstPage.CenterHeader.Text = ""
        .FirstPage.RightHeader.Text = ""
        .FirstPage.LeftFooter.Text = ""
        .FirstPage.CenterFooter.Text = ""
        .FirstPage.RightFooter.Text = ""
    End With
    Application.PrintCommunication = True
    Range("A1:F1").Select
End Sub
After I've saved the macro and try to run it in a spreadsheet, the logo doesn't load. Instead I see &R.
I also inserted a page number into the macro as well but that doesn't load either. I'm using excel 2010.
I'm running the exact same macro on another computer running excel 2013 and that works perfectly.

Can anybody shed some light on this issue?

Thanks a lot,

Amit
 
Last edited by a moderator:

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Try moving this line:

Code:
Application.PrintCommunication = False

after the lines that set the headers (or remove it altogether).
 
Upvote 0
That solved it!! :)
Thank you very much RoryA. You just saved me a lot of headache. :)

Much appreciated man. :)


Try moving this line:

Code:
Application.PrintCommunication = False

after the lines that set the headers (or remove it altogether).
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,262
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top