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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

bobsan42

Well-known Member
Joined
Jul 14, 2010
Messages
1,393
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
Platform
  1. Windows
Clicking on what?
If it is a command button - disable it on clicking and then enable it again when done.
 

RiTiNi

New Member
Joined
Dec 17, 2020
Messages
3
Office Version
  1. 2010
Platform
  1. Windows
thnx for the swift reply.
It's clicking on the template-file to open excel and start a new workbook
 

bobsan42

Well-known Member
Joined
Jul 14, 2010
Messages
1,393
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
Platform
  1. Windows
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
 
Solution

RiTiNi

New Member
Joined
Dec 17, 2020
Messages
3
Office Version
  1. 2010
Platform
  1. Windows
Thnx for teh solution.
I've added to the script and no-more complains or fault-messages.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,483
Messages
5,636,596
Members
416,927
Latest member
BNM8V6

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
Top