98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft VBA Training and help » Problem with Workbook.activate command
Problem with Workbook.activate command
Resolved · Medium Priority · Version 2003
Michael has attended:
No courses
Problem with Workbook.activate command
I am having a problem with using the workbook.activate command across different users in my office. We are all running the same version of excel, but on some computers the code errors, as an example consider a workbook called "Example" that I would like to select as part of the program, on the problem computers this errors out at the line:
Workbooks("Example").activate
the error message stipulates that basically it doesn't understand the command. on the problem computers I ahve done the obvious things such as install the VBA and VBA analysis toolpacks, and this has not resolved the issue.
When I comment out the problem line the program runs without an issue, can anyone help me with this?
RE: Problem with Workbook.activate command
Thank you for your question.
One thing that might be causing the error is the missing extension from the workbook name. Do the PCs having problems have autosave turned on? Saving for some reason adds the extension to the name. So the following would work after a save
Workbooks("Example.xls").Activate
If that is not the issue then you possible could at a point when you know Example is the activeworkbook, for example when you open or create it and use the following
Dim wkExample as Workbook
Set wkExample = ActiveWorkbook
And then later when you need to activate it.
wkExample.Activate
I hope that helps
Laura GB
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
VBA tip:Use GoTo to Select A Cell With VBATo select a certain cell on a Worksheet you can use: |