Hi All,
I'm semi experienced with VBA codes but have never written one to run upon the document opening. I tried following this guide Run a Macro Automatically on Opening Excel Workbook - VBA Examples but couldn't get it to do what I want it to do.
1. Essentially I want users to have the option to be able to refresh the data (this will then save the document as part of the refresh, so that the next person won't need to).
2. However I don't want people to be able to manually save the document!! I've had experience with people messing around with these things before.
So obviously I can't just set to read only because then they can't save as part of the refresh. My idea was to write a Macro that runs when the document is opened; this needs to disable save and save as (hopefully with a polite message). I tried following this guide but couldn't get it working excel vba - How to Disable Save and Save As using VBA - Stack Overflow
Then the refresh macro I already have as this
It just needs a line of code adding in to enable saving before saving and disable saving afterwards...
But how the heck do I get the saving when opening disabled? Is there some extra trick which I'm missing with getting a macro to run upon opening? Is there some extra trick I'm missing with getting controls disabled?
Thanks In Advance!! Andrew
I'm semi experienced with VBA codes but have never written one to run upon the document opening. I tried following this guide Run a Macro Automatically on Opening Excel Workbook - VBA Examples but couldn't get it to do what I want it to do.
1. Essentially I want users to have the option to be able to refresh the data (this will then save the document as part of the refresh, so that the next person won't need to).
2. However I don't want people to be able to manually save the document!! I've had experience with people messing around with these things before.
So obviously I can't just set to read only because then they can't save as part of the refresh. My idea was to write a Macro that runs when the document is opened; this needs to disable save and save as (hopefully with a polite message). I tried following this guide but couldn't get it working excel vba - How to Disable Save and Save As using VBA - Stack Overflow
Then the refresh macro I already have as this
Code:
Sub Refresh()ActiveWorkbook.Model.Refresh
Range("B2").Value = Now()
ActiveWorkbook.RefreshAll
ThisWorkbook.Save
MsgBox ("Refresh Complete")
End Sub
It just needs a line of code adding in to enable saving before saving and disable saving afterwards...
But how the heck do I get the saving when opening disabled? Is there some extra trick which I'm missing with getting a macro to run upon opening? Is there some extra trick I'm missing with getting controls disabled?
Thanks In Advance!! Andrew