Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-04-07
4
Medium Priority
?
414 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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 article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

916 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