Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Compile Error

I can not figure out why I get a Compile Error (Expected Function or
Variable). It stops at : Module Protection.unprotect_all_sheets. If I
run the module on its own it works fine.


Private Sub CommandButton1_Click()

On Error GoTo Error

'ActiveWorkbook.ChangeFileAccess Mode:=xlReadWrite
Worksheets("January").Protect Password:="popcorn"


If TextBox1.Text = "popcorn" Then
Module Protection.unprotect_all_sheets
End If

If TextBox1.Text < "popcorn" Then
Unload UserFormPassword
MsgBox "Invalid password - you cannot access this"

ThisWorkbook.Close False

Exit Sub

Else

Unload UserFormPassword

End If

Worksheets("January").Protect Password:=""

GoTo LastLine

Error:

ThisWorkbook.Close False

LastLine:

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Compile Error

If you're trying to run the unprotect_all_sheets procedure in the Protection
module:

Call Protection.unprotect_all_sheets
or
Protection.unprotect_all_sheets

If you don't have procedures with the same name, you could do:
Call unprotect_all_sheets
or
unprotect_all_sheets

(The module name isn't always necessary.)

Patrick Simonds wrote:

I can not figure out why I get a Compile Error (Expected Function or
Variable). It stops at : Module Protection.unprotect_all_sheets. If I
run the module on its own it works fine.

Private Sub CommandButton1_Click()

On Error GoTo Error

'ActiveWorkbook.ChangeFileAccess Mode:=xlReadWrite
Worksheets("January").Protect Password:="popcorn"

If TextBox1.Text = "popcorn" Then
Module Protection.unprotect_all_sheets
End If

If TextBox1.Text < "popcorn" Then
Unload UserFormPassword
MsgBox "Invalid password - you cannot access this"

ThisWorkbook.Close False

Exit Sub

Else

Unload UserFormPassword

End If

Worksheets("January").Protect Password:=""

GoTo LastLine

Error:

ThisWorkbook.Close False

LastLine:

End Sub


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
help with this error-Compile error: cant find project or library JackR Excel Discussion (Misc queries) 2 June 10th 06 09:09 PM
VBAProject name compile error, not defined at compile time Matthew Dodds Excel Programming 1 December 13th 05 07:17 PM
error message: compile error, argument not optional Pierre via OfficeKB.com Excel Programming 3 September 5th 05 03:45 PM
How do I get rid of "Compile error in hidden module" error message David Excel Discussion (Misc queries) 4 January 21st 05 11:39 PM


All times are GMT +1. The time now is 08:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"