Run Time Error on Certain Builds Only

teefy

New Member
Joined
Mar 2, 2009
Messages
31
Hello there!

I need to disable AutoSave in a certain file when opening. The solution posted here works fine on my machine with Excel 365, however other people have encountered problems.

I have Office 365, but others have Office 2016 (both of which are considered Version 16 apparently, albeit with different Builds).

I tried adapting the code linked above to include a Build number, so that it would only run recent builds of Excel:

VBA Code:
If Val(Application.Version) >= 16 And Val(Application.Build) >= 11126 Then
    If ThisWorkbook.AutoSaveOn Then ThisWorkbook.AutoSaveOn = False
End If

But this still gives a "Method or data member not found" error on older Excel builds at compile, because evidently they simply don't have "AutoSaveOn" available.

How can I get the If ThisWorkbook.AutoSaveOn Then ThisWorkbook.AutoSaveOn = False code to only run if the function exists (i.e. recent builds) and not fall over on older ones?

Thanks very much!
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Try moving it to a different Sub & calling it like
Code:
If Val(Application.Version) >= 16 And Val(Application.Build) >= 11126 Then
    Call SwitchOff
End If
End Sub

Sub SwitchOff()
    If ThisWorkbook.AutoSaveOn Then ThisWorkbook.AutoSaveOn = False
End Sub
 
Upvote 0
Try moving it to a different Sub & calling it like
Code:
If Val(Application.Version) >= 16 And Val(Application.Build) >= 11126 Then
    Call SwitchOff
End If
End Sub

Sub SwitchOff()
    If ThisWorkbook.AutoSaveOn Then ThisWorkbook.AutoSaveOn = False
End Sub
Thank you, that worked... I also found that when I used ActiveWorkbook.AutoSaveOn rather than ThisWorkbook.AutoSaveOn it doesn't error.

My fault, I changed that from the thread I referenced initially. I just prefer ThisWorkbook normally, as I know exactly what it's referring to.

Much obliged!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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