run-time error 9

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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.
 
Back
Top