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?
 

Some videos you may like

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

bobsan42

Well-known Member
Joined
Jul 14, 2010
Messages
1,364
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,364
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,128,110
Messages
5,628,761
Members
416,337
Latest member
tl3phd

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