problem workbookactivate command
RH

Forum home » Delegate support and help forum » Microsoft VBA Training and help » Problem with Workbook.activate command

Problem with Workbook.activate command

resolvedResolved · 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

RE: Problem with Workbook.activate command

Thanks Laura,

You were right it was a problem over the extension not being listed, I have made the necessary adjustments and now my code works perfectly.

Thanks again

Michael

 

Training courses

 

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
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

VBA tip:

Use GoTo to Select A Cell With VBA

To select a certain cell on a Worksheet you can use:

Application.Goto Reference:=Range("V300")

or more simply

Range("V300").Select

If, on the other hand, you want the selected cell to be the top/left cell on the screen you use:

Application.Goto Reference:=Range("V300"), Scroll=True

View all VBA hints and tips


Server loaded in 0.06 secs.