Code stops on successful Workbook Open

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
20,347
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

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
I saw a post in here somewhere that said something like that happened if the book was in "Design Mode"...

Not sure if that helps...
 
Upvote 0
HOTPEPPER

How about dropping the On Error Resume Next?

Though you've probaly tried that already.:)
 
Upvote 0
If I open the sheet directly, the design mode icon is not highlighted, but if I open it with my code it is, how do I stop that?
 
Upvote 0
I was trying to find some code for it, but I'm not sure.

ActiveWorkbook.ToggleFormsDesign

will turn it on...

but repeating it does not turn it off

ActiveWorkbook.ToggleFormsDesign = False
does not work either...


did you ReSave the file with it Off ??

I only remember seeing the post, don't think there was a resolution. I was just Hoping to point in a direction.
 
Upvote 0
No. I don't know if it matters but the sheets I'm trying to open in this workbook were created from another workbook macro and e-mailed from within the other macro. Although if I open the sheets manually they are not in Design Mode.
 
Upvote 0

Forum statistics

Threads
1,215,330
Messages
6,124,310
Members
449,152
Latest member
PressEscape

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