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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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