Header Footer Editor VBA

smit3446

New Member
Joined
Nov 16, 2015
Messages
44
I'm having issue with a macro that I never used to have issues with. The code goes through the Header/Footer of each worksheet within the workbook and updates it with three lines in the Left Header:

Company Name
Program
Effective Date

It also adds in a logo that we use in the right footer and sheet name in the left footer. Here is the code:

Code:
Sub header_footer_unscale_new()Dim ws As Worksheet




For Each ws In ActiveWorkbook.Worksheets
   
    With ws.PageSetup
        .ScaleWithDocHeaderFooter = False
        .TopMargin = Application.InchesToPoints(0.9)
        .LeftHeader = "&""Arial,Bold""&8Company Name" & vbCr & "Program" & vbCr & "Effective July 1, 2018"
        .RightHeader = ""
        .LeftFooter = "&""Arial Narrow,Regular""&A"
        .RightFooter = "&G" 'specifies that you want an image in your footer
        .RightFooterPicture.Filename = "C:\Users\User1\Desktop\Excel Logo.jpg" 'specifies the image file
        
    End With
    ActiveWindow.View = xlNormalView
    Range("A1").Activate
    
Next
            
End Sub


I'm getting a Run-time error 1004 with the following line:

Code:
        .LeftHeader = "&""Arial,Bold""&8Company Name" & vbCr & "Program" & vbCr & "Effective July 1, 2018"

Is the syntax off? What am I doing wrong? Thanks in advance.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
.
Ran your macro just as posted and it works fine here for all sheets.

?????
 
Upvote 0
Well at least I know I'm not going crazy, I couldn't figure it out (still can't). I've never ran into this problem before.
 
Upvote 0
Sometimes my computer will act up when using Excel. If I reboot, oftentimes the squirrely errors disappear.

Go figure.
 
Upvote 0

Forum statistics

Threads
1,214,950
Messages
6,122,438
Members
449,083
Latest member
Ava19

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