Something strange is happening...!

Glove303

Board Regular
Joined
Dec 18, 2010
Messages
65
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.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
38,775
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
38,775
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
65
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
38,775
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
38,775
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
I know a few bits and pieces, yes. :)
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,707
Messages
5,833,242
Members
430,199
Latest member
Petty queen

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