roelandwatteeuw
Board Regular
- Joined
- Feb 20, 2015
- Messages
- 87
- Office Version
- 365
- Platform
- Windows
Hi all
You probably all know the AutoSave in Excel.
And probably a lot will know how to disable it with VBA.
Situation:
When a user is opening this file for the first time, Excel will ask to 'Enable Content' for security reasons.
Before Enabling this option, the file will still be in AutoSave-mode.
After Enabling it will run my macro in 'Workbook_Open' in 'ThisWorkbook'.
This macro contains first off all the code to disable the AutoSave.
After this, in the same macro, an InputBox will pop-up where the user needs to fill in some info.
My file also contains a macro 'Workbook_BeforeSave'.
This to avoid users to save the file without using a 'Save-button' I made.
If they're trying to save it without the button, it will show an alert that they have to use the button.
Problem:
After completing the InputBox, Excel shows me the Alert that I have to use the button --> The alert made in the 'Workbook_BeforeSave'.
The InputBox seems to be handled before disabling the AutoSave.
So AutoSave is still On when the InputBox appears.
I can't find a solution to make it work and avoid the alert.
Some of my code:
You probably all know the AutoSave in Excel.
And probably a lot will know how to disable it with VBA.
VBA Code:
Sub Workbook_Open()
ActiveWorkbook.AutoSaveOn = False
End If
Situation:
When a user is opening this file for the first time, Excel will ask to 'Enable Content' for security reasons.
Before Enabling this option, the file will still be in AutoSave-mode.
After Enabling it will run my macro in 'Workbook_Open' in 'ThisWorkbook'.
This macro contains first off all the code to disable the AutoSave.
After this, in the same macro, an InputBox will pop-up where the user needs to fill in some info.
My file also contains a macro 'Workbook_BeforeSave'.
This to avoid users to save the file without using a 'Save-button' I made.
If they're trying to save it without the button, it will show an alert that they have to use the button.
Problem:
After completing the InputBox, Excel shows me the Alert that I have to use the button --> The alert made in the 'Workbook_BeforeSave'.
The InputBox seems to be handled before disabling the AutoSave.
So AutoSave is still On when the InputBox appears.
I can't find a solution to make it work and avoid the alert.
Some of my code:
VBA Code:
Sub Workbook_Open()
Dim NeededInfo as String
On Error Resume Next
Sheets("RBD").Select
If ActiveWorkbook.AutoSaveOn = True Then
ActiveWorkbook.AutoSaveOn = False
End If
NeededInfo = InputBox("Give me the info", "Information", NeededInfo)
Range("J1").Value = NeededInfo
End Sub
VBA Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True
MsgBox "The file has not been saved!" & vbCrLf _
& "Use the Save-Button."
End Sub