run-time error 9

L

LHearn

When I run the following code, I get a run-time error 9 message. Does anyone
have any ideas? we are trying to make a new timecard program for our
employees and this macro was working just fine yesterday. The code is
designed to unprotect the sheet in the workbook, spell-check it, then
re-protect the sheet. Any assistance is much appreciated.

' Keyboard Shortcut: Ctrl+s
'
Windows("2005 Master Timecard.xls:2").Activate
ActiveSheet.Unprotect Password:="bear"
Range("G1:G70").Select
Selection.CheckSpelling SpellLang:=1033
ActiveSheet.Protect Password:="bear"
End Sub
 
R

Rob Bovey

Try changing the line:

Windows("2005 Master Timecard.xls:2").Activate

to this:

Workbooks("2005 Master Timecard.xls").Activate

Note the use of the Workbooks method rather than the Windows method and the
removal of the Window counter from the end of the workbook name.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm
 
J

JMB

Also, ensure Master Timecard workbook is open (unless you have code that
automatically opens it) and make sure the workbook name has not changed.
Somtetimes people change the workbook name w/o updating the code to reflect
the new name.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top