Prefenting opening template twice

RiTiNi

New Member
Joined
Dec 17, 2020
Messages
3
Office Version
  1. 2010
Platform
  1. Windows
Hello VBA Masters,

I am looking for a vba script that prevents clumsy clicking (multiple times instead of double) when opening a template (excel) that causes two script sessions to run together with errors as a result.
Anyone an idea to solve this phenomenon?
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Clicking on what?
If it is a command button - disable it on clicking and then enable it again when done.
 
Upvote 0
thnx for the swift reply.
It's clicking on the template-file to open excel and start a new workbook
 
Upvote 0
It feels a bit weird to me to start excel in this way, but anyway ...
You can use an Application level variable to control if the code/scripts will run or not.
e.g. Application.EnableEvents, .EnableAnimations, .DisplayAlerts etc.

VBA Code:
Private Sub Workbook_Open()
    If Application.EnableEvents Then
        Application.EnableEvents = False
        Call your_code
        Application.EnableEvents = True
    End If
End Sub
 
Upvote 0
Solution
Thnx for teh solution.
I've added to the script and no-more complains or fault-messages.
 
Upvote 0

Forum statistics

Threads
1,214,386
Messages
6,119,215
Members
448,874
Latest member
b1step2far

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