VBA runs differently based on how Excel is opened

mikechambers

Active Member
Joined
Apr 27, 2006
Messages
397
I realize since I'm using VBA that this is code specific in a way, but I'm more or less trying to understand why Excel behaves differently based on how it's opened.

Method 1: Opening a workbook from File-Open within an existing Excel application instance.

Method 2: Opening the workbook from Windows Explorer, thereby launching an instance of Excel an opening the file.

Opening my workbook using Method 1 works like I want it, but opening it using Method 2 fails on the Workbook Open procedure. In this particular case, Method 2 opens it in Protected View (which I don't understand why, and after clicking Enable, then it fails on "Object variable or With block variable not set" and the line of code is "ActiveWindow.DisplayHeadings = False"

Can anyone help me understand what is going on here? I search extensively on this, but I'm unclear how to even search it.

I should add, Method 2 only fails when the file is located on a SharePoint site location. When I move it to the desktop, or a network drive, Method 2 and Method 1 are the same. I just figured that part out.
 
Last edited:

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,215,013
Messages
6,122,690
Members
449,092
Latest member
snoom82

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