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

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
40,344
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
Try moving this line:

Code:
Application.PrintCommunication = False

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

ldhawan

New Member
Joined
Jun 20, 2016
Messages
14
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,190,616
Messages
5,981,956
Members
439,745
Latest member
VBANewbieJohn

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
Top