Macro slows down opening time of workbook.

Grompey

New Member
Joined
Jul 19, 2023
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hello Excel gurus,

I have a question about a Macro I would like to use, however the macro increases the opening time of the workbook a lot which is kind of annoying.
The macro is as follows:

VBA Code:
Private Sub Workbook_Open()
    Dim sh As Worksheet
    For i = 1 To ActiveWorkbook.Sheets.Count
        Set sh = ActiveWorkbook.Sheets(i)
        With sh.PageSetup
        .LeftFooterPicture.FileName = "C:\\MyFile"
        .CenterFooter = "&""Tahoma""&10ActiveWorkbook.FullName"
        .RightFooter = "&""Tahoma""&10Page &P of &N "
        .LeftMargin = Application.CentimetersToPoints(1.5)
        .RightMargin = Application.CentimetersToPoints(0.5)
        .TopMargin = Application.CentimetersToPoints(1.2)
        .BottomMargin = Application.CentimetersToPoints(1.6)
        .HeaderMargin = Application.CentimetersToPoints(0.4)
        .FooterMargin = Application.CentimetersToPoints(0.8)
        End With
    Next i
End Sub

Is there a solution to make the macro run quicker? Especially with some of the bigger workbooks it will take almost 5 min to complete its cycle.
Thank you very much in advance.

Kind Regards,

Grompey
 
Last edited by a moderator:

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Try turning off Application.PrintCommunication before starting the loop and turning it back on afterwards.
 
Upvote 0
Also, when posting vba code in the forum, please use the available code tags. It makes your code much easier to read/debug & copy. My signature block below has more details. I have added the tags for you this time. 😊
 
Upvote 0
Also, when posting vba code in the forum, please use the available code tags. It makes your code much easier to read/debug & copy. My signature block below has more details. I have added the tags for you this time. 😊
Thanks, I forgot it for this post.
 
Upvote 0

Forum statistics

Threads
1,215,751
Messages
6,126,669
Members
449,326
Latest member
asp123

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