Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel: Spell Check while Sheet is locked

Status
Not open for further replies.

Benoni2

Programmer
Jul 27, 2005
30
US
I have form in excel. I have locked most of the cells except for the four on the page that I want the user to type into. I then want them to be able to spell check those four cells using a button.

Problem: Though this works fine when the sheet is not protected, as soon as I protect the sheet, the macro/vba fails to exicute. Is there any way to fix this?
 


Hi,

Then, in your macro,

unprotect
macro code
protect

Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
So this is the code:

Sub button_spellcheck()
'
' button_spellcheck Macro
' Macro recorded 9/13/2005 by Benjamin Shier
'

'

Range("B15,B12,B9,B6").Select
Range("B6").Activate
Selection.CheckSpelling SpellLang:=1033

End Sub


How do you write protect and unprotect in there? I tried something like ActiveWorkbook.Unprotect and then ActiveWorkbook.Protect before and after my three lines of code. Not sure what I need.
 


Code:
Sub button_spellcheck()
'
' button_spellcheck Macro
' Macro recorded 9/13/2005 by Benjamin Shier
'

'unprotect here

    Range("B15,B12,B9,B6").Select
    Range("B6").Activate
    Selection.CheckSpelling SpellLang:=1033
'protect here

End Sub

Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
Sub button_spellcheck()
Is this what I need? It doesn't seem to be working for me in Excel 2003


' button_spellcheck Macro
' Macro recorded 9/13/2005 by Benjamin Shier
'

'
ActiveWorkbook.Unprotect

Range("B15,B12,B9,B6").Select
Range("B6").Activate
Selection.CheckSpelling SpellLang:=1033
Range("B6").Select

ActiveWorkbook.Protect
End Sub
 

Did you protect your workbook or did you protect your worksheet?

Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
oops! I protect each worksheet differently on each page, I don't protect the workbook as a whole.
 
Thanks for your patience. how do you reference the current worksheet?
 
ActiveSheet.Unprotect......

Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
I'm assuming I could adapt this to work for a shared workbook as well?
 


Yes, but....

there are restriction regarding shared workbooks. you need to understand what they are and how they relate to your code.

Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top