KenMcKenzie

New Member
Joined
Mar 14, 2018
Messages
2
Hi. Apologies if I haven't got this right or if the thread exists -this is the first time I've posted.
I've set up some code to switch off that pesky Autorecover. Below is the code in PERSONAL.xlsb:ThisWorkbook:

Code:
Public WithEvents App As Application

Private Sub Workbook_Open()
    'runs once per Excel session when Personal.xlsb is opened
    'Needed to make next sub work
      Set App = Application
    End Sub

Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
    'This will run everytime a workbook is opened
     If ActiveWorkbook.AutoSaveOn = True Then ActiveWorkbook.AutoSaveOn = False
    End Sub
This works fine when opening a workbook from within Excel. But if Excel isn't running and you double-click a file in Explorer, you get Runtime error '91' - variable not set.
I've tried various WAITs to allow Excel to open fully but doesn't make any difference.
Any suggestions would be appreciated.
KenMcKenzie
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Welcome to the forum.

That code should actually be:

Code:
Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
    'This will run everytime a workbook is opened
     If wb.AutoSaveOn = True Then wb.AutoSaveOn = False
    End Sub
 
Upvote 0
Welcome to the forum.

That code should actually be:

Code:
Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
    'This will run everytime a workbook is opened
     If wb.AutoSaveOn = True Then wb.AutoSaveOn = False
    End Sub

Thank you for such a quick reply.
And it works perfectly.
What a great forum.

KenMcKenzie
 
Upvote 0

Forum statistics

Threads
1,215,327
Messages
6,124,290
Members
449,149
Latest member
mwdbActuary

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