Code stops on successful Workbook Open

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
20,367
Office Version
  1. 365
Platform
  1. Windows
Hi, I have the following code.
The code completely stops if it successfully opens the workbook. No error, it just opens the workbook and then nothing else happens.
I have put in a checkpoint in the code to see if it actually gets that far and it only continues the code if the file did not exist.
Column A does contain valid dates in the workbook this code is running from. Any ideas?

Code:
Sub GetPressRun()
On Error Resume Next
Dim fp As String, cf As String, fn As String, dt As Date
Dim li As Range

Set li = Cells(ActiveCell.Row, 1)
dt = li
fp = "J:\Paper Sections\pressrun\"
fn = "Run Sheet (" & Format(dt, "m-d-yyyy") & ").xls"

If Dir(fp & fn) <> "" Then
    Workbooks.Open fp & fn
Else
    MsgBox "Press Run for date " & dt & " does not exist", vbExclamation
    Exit Sub
End If

'Checkpoint #1
cf = ActiveWorkbook.Name
MsgBox cf

With Workbooks(fn).Sheets(1)
    li.Offset(, 1) = .Range("E34")
    li.Offset(, 4) = .Range("E25")
    li.Offset(, 12) = .Range("E29") + .Range("E30")
End With

Workbooks(fn).Close False
End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Sounds (to me anyway) like your workbook is being opened w/o macros enabled. Have you tried adding a digital signature or checking your security level? Have you tried running other code?
 
Upvote 0
Sounds (to me anyway) like your workbook is being opened w/o macros enabled. Have you tried adding a digital signature or checking your security level? Have you tried running other code?
 
Upvote 0
I write and run all sorts of macros. Security Level is set to Low.
 
Upvote 0
OK. if I run the macro by hitting ALT-F8 and hitting Run, it works fine, but if I run it with a shortcut key it does not.
 
Upvote 0
What is the shortcut key? Does it involve shift? That will open a workbook in design mode I believe?
 
Upvote 0
Yes, CTRL-SHIFT-F.
I always use shifted shortcuts to avoid interfering with the normal shortcut keys.
 
Upvote 0
Well sounds like you're getting to the root of the problem. I have had that problem as well with the Shortcut key.

Back to one of my other posts here, about
ActiveWorkbook.ToggleFormsDesign

That turns ON Design Mode.
If someone could find a code to turn it OFF, that would be great.

I would think by the Name ToggleFormsDesign
That simply running it over and over would turn it On/Off/On/Off etc...

But it doesn't...I don't know why.
Anybody?
 
Upvote 0
I have done some testing and it seems that everytime I used shift as a shortcut to call a macro that opened a workbook it would open in design mode even with low security. So it looks that we need to find a solution to what Jonmo is getting at. I don't know why it does it.
 
Upvote 0

Forum statistics

Threads
1,216,028
Messages
6,128,399
Members
449,447
Latest member
M V Arun

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