Solved

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

Posted on 2014-04-07
4
338 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now