I'm running office 2010 and recently added visual studio pro 2008 (requried by a project I am starting).  I've also kept up with Microsoft updates so I've made some of those too.  How my excel VBA macros don't work.  A snippet of code which stops with "application defined or object-defined error on the last line.

Range("end_end").value = activerows + 5
ActiveWorkbook.Names("Master").RefersTo = "=pricing!$f$6:$bn$" & LTrim(Str(activerows + 5))
ActiveWorkbook.Names("Dealers").RefersTo = "personal.xls!dealers"
noter = 0

pr = "$a$1:$bn$" & LTrim(Str(activerows + nr + 6))
ActiveSheet.PageSetup.PrintArea = pr

Code worked before but not now
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Saqib Husain, SyedEngineerCommented:
What is the value of pr at this stage?
dsackerContract ERP Admin/ConsultantCommented:
You may need to post your xlsx files (or an excerpt representation of them). Trying to reproduce your code is not possible, considering it is guesswork to set up the Master, Dealers, Pricing and Personal.xls references.

Other than that, I got no error on the line: ActiveSheet.PageSetup.PrintArea = pr
However, I fudged the value in "pr".
NorieAnalyst Assistant Commented:
Where does the error occur?

Have you stepped through the code to check the values of the variables?

By the way, why are you using LTrim and Str?

You shouldn't need thten when concatenating.
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

AVSteveAuthor Commented:
ok, I've learned some more.  My macros come (for the most part) from a personal.xls which is xlstart so it always there.  the file is hidden so it doesn't confuse a user,  All used to work.  Now with the updates it doesn't work --- sortof.

If I open the macro file itself and run the macro (no hidden macro file), it works.  if I remove the hidden macro file, start a new program copy the macro in -- it works.

The problem is that the macro comes from what I would call a macro library and when running is confused about what an "actitivesheet" is.   Is there a different way to do a macro library?  A way to ensure the right context?  A way to say activesheet (and similar) without saying it?
AVSteveAuthor Commented:
Apparently the righter-way for a macro library is an add-in.  I tried that.  Still no joy.  And the problem also effects the selection object as well as the active sheet one.
Wayne Taylor (webtubbs)Commented:
ActiveSheet used in the Personal.xlsx file will work fine. I suspect the error lies elsewhere. Please try what Norie stated and step through the macro and check the values of "activerows" and "nr" (hover over them to view their values)
AVSteveAuthor Commented:
Problem solved: The code had been running in compatability mode.   Apparently one of the Office 2010 upgrades i did caused the functionality of that mode to be more restrictive.   If I convert the file, it runs correctly.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AVSteveAuthor Commented:
The other answers might have led to this resolution but they never followed up their initial posts.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.