Forum Discussion

John_McDonald_081301's avatar
John_McDonald_081301
Copper Contributor
May 17, 2024

Excel Auto Open Macro

I bought a book on VBA programming for MS Office and I'm trying to do one of the examples. It's a macro that automatically maximizes the window and opens the most recent document when you start excel, but it's not working. There is no error message, excel just opens like normal. I've gone through the instructions a couple of times but can't find any issues. My code is below:

 

Option Explicit

Private Sub Auto_Open()

Application.WindowState = xlMaximized

Application.RecentFiles(1).Open

 

End Sub

 

Any thoughts? Thanks in advance.

Resources