Solved

Getting "Object variable...not set" on ActiveWorkbook after  "Enable Editing"

Posted on 2014-04-07
4
357 Views
Last Modified: 2014-04-08
Hello - in the Workbook_Open event, I do some initialization things like protecting the workbook, protect the individual worksheets, and hide some columns on a data input worksheet.

I was ready to roll this out, but when I changed the workbook file name, the first time opening it, everything stopped until I answered the prompt about "Enable Editing". After I click that button, then I get the Object variable... not set".

Shouldn't ActiveWorkbook always be set?

Thanks
0
Comment
Question by:mlagrange
  • 2
4 Comments
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 39984348
what line of code triggers the error?
0
 

Author Comment

by:mlagrange
ID: 39984388
ActiveWorkbook..Unprotect Password = strMyPassword

I unprotect the workbook first in case it is still protected, so I can hide tabs that may or may not be hidden.
strMyPassword is Dim'd as: Global Const strMyPassword as string = ...
0
 
LVL 35

Accepted Solution

by:
Bembi earned 500 total points
ID: 39984412
In general yes..., but....
As you open a workbook from a "non trusted" location, the question is what happens first.
The behaviour of macros depend on the security settings for the client (if excel is allowed to proceed macros in general) and second on the location, where they are stored.
If Excel opens a file from a "non trusted"location, everything is blocked first until you agree to open it. If the macros are allowed to run at this time, the macro can not find the object, as it was blocked before.

So you have to make sure, that the macro is allowed to run and that excel recognized the file location as trusted before it tries to open it.

Thruste file locations can be set in the security settings (Excel) on the local machine or you can setup GPOs to define truted locations.
0
 

Author Closing Comment

by:mlagrange
ID: 39985813
Ok, thanks, that explains it. As it turns out, I'm lucky; this thing will live on SharePoint, and it doesn't have this problem opening up from there.

Thanks again
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question