Solved

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

Posted on 2014-04-07
4
365 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: 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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

751 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