Something strange is happening...!

Glove303

Board Regular
Joined
Dec 18, 2010
Messages
57
I have a procedure that works fine when it is called from another procedure (no variables passed between then 2), and works fine when I step through it manually. However, it just "gives" up when I run it directly.

It fails at the same line of code, but does not report an error, and as I say, stepping through it manually causes now problem.

OldTemp = Application.GetOpenFilename(FileFilter:= _
"Excel Files (*.xls), *.xls", Title:="Please select a file")

If OldTemp = False Then Exit Sub

Application.EnableEvents = False
Set OldTT = Workbooks.Open(OldTemp)
Application.EnableEvents = True

It fails on the penultimate line (Set OldTT = Workbooks.Open(OldTemp))


James.
 

Some videos you may like

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,133
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
How are you running it when you run it directly? From a keyboard shortcut?
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,133
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS

ADVERTISEMENT

Does your shortcut involve the Shift key, and does the workbook that you are opening have code in the Open event? If so, try a shortcut that does not use Shift.
 

Glove303

Board Regular
Joined
Dec 18, 2010
Messages
57
Does your shortcut involve the Shift key, and does the workbook that you are opening have code in the Open event? If so, try a shortcut that does not use Shift.

Yes and Yes!

It is Ctl + Shift + U

And the workbook has a procedure in the open event.

Is this an Excel bug? I will change the shortcut.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,133
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS

ADVERTISEMENT

Yes, it's a bug. It relates to the use of the Shift key to prevent event code running when you open a file manually.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,133
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
I know a few bits and pieces, yes. :)
 

Watch MrExcel Video

Forum statistics

Threads
1,123,143
Messages
5,599,975
Members
414,354
Latest member
Flaxarn

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