Scope of Subs?
Hi Ken,
Look again at my example and change:
ProjectExpired
to:
ThisWorkbook.ProjectExpired
---
Regards,
Norman
"Ken Loomis" wrote in message
...
I tried that.
Here is the workbook sub I am trying to call from a module:
Public Sub ProjectExpired()
Dim ErrorMessage As StreetLeads
ErrorMessage = "This workbook has expired." & vbNewLine
ErrorMessage = ErrorMessage & "Please contact the programmer for a new
version." & vbNewLine
MsgBox (ErrorMessage)
NewDeleteAllCode
mySave = True
ActiveWorkbook.Save
mySave = False
End Sub
Here is the call to that sub:
If IITTDH ExpTest Then
ProjectExpired
Exit Sub
End If
When I compile the project, I get a Compile error: Sub or function not
defined with ProjectExpired highlighted in the module code.
Any suggestions?
Thanks,
Ken
"Norman Jones" wrote in message
...
Hi Ken,
You can call a sub in the Thisworkbook module if the sub is declared
public.
For example:
In the ThisWorkbook module:
'-------------------------------
Public Sub Workbook_Open()
MsgBox "Hello from Workbook_Open!"
End Sub
In a standard module:
---------------------
Sub CallIt()
ThisWorkbook.Workbook_Open
End Sub
---
Regards,
Norman
"Ken Loomis" wrote in message
...
I am trying to call a sub in the workbook object from a sub in a module,
but I can't seem to make that work.
Is there a way to make that work?
TIA,
Ken
|