Header Footer Editor VBA

smit3446

New Member
Joined
Nov 16, 2015
Messages
46
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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
.
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,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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