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.
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".
Norie
Where does the error occur?
Have you stepped through the code to check the values of the variables?
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?
AVSteve
ASKER
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)
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)