Making a Msgbox popup

T

Todd Huttenstine

This code is also from Chip Pearsons website.
The below code sees if a procedure or function is there.
How do I make it to where an input box comes up and then I
type the name of the procedure or sub in and it tell me
the output in a msgbox?

Thanx

Function ModuleExists(ModuleName As String) As Boolean
On Error Resume Next
ModuleExists = Len( _
ThisWorkbook.VBProject.VBComponents(ModuleName).Name) <> 0
End Function
Function ProcedureExists(ProcedureName As String, _
ModuleName As String) As Boolean
On Error Resume Next
If ModuleExists(ModuleName) = True Then
ProcedureExists = ThisWorkbook.VBProject.VBComponents
(ModuleName) _
.CodeModule.ProcStartLine(ProcedureName,
vbext_pk_Proc) <> 0
End If
End Function
 
R

Rob van Gelder

Sub testit()
Dim strModuleName As String, strProcedureName As String

strModuleName = InputBox("Module?")
If strModuleName <> "" Then
strProcedureName = InputBox("Procedure?")
If strProcedureName <> "" Then
MsgBox IIf(ProcedureExists(strProcedureName, strModuleName),
"Exists", "Not Exists")
End If
End If
End Sub
 
T

Todd

Ah thank you. It works!

Todd
-----Original Message-----
Sub testit()
Dim strModuleName As String, strProcedureName As String

strModuleName = InputBox("Module?")
If strModuleName <> "" Then
strProcedureName = InputBox("Procedure?")
If strProcedureName <> "" Then
MsgBox IIf(ProcedureExists(strProcedureName, strModuleName),
"Exists", "Not Exists")
End If
End If
End Sub





.
 
T

Todd Huttenstine

Is there anyway to break them up where I can input a
module and see if it exists or a procedure instead of both
popup boxes coming up at the same time
 
R

Rob van Gelder

Todd,

Sub testit()
Dim strModuleName As String, strProcedureName As String
Dim blnExists As Boolean

strModuleName = InputBox("Module?")
If strModuleName <> "" Then
strProcedureName = InputBox("Procedure?" & vbNewLine & "Leave blank
or cancel to check for module only")
If strProcedureName = "" Then
blnExists = ModuleExists(strModuleName)
Else
blnExists = ProcedureExists(strProcedureName, strModuleName)
End If
MsgBox IIf(blnExists, "Exists", "Not Exists")
End If
End Sub

Rob
 
T

Todd Huttesntine

Thank you, thats what I wanted.

Todd

-----Original Message-----
Todd,

Sub testit()
Dim strModuleName As String, strProcedureName As String
Dim blnExists As Boolean

strModuleName = InputBox("Module?")
If strModuleName <> "" Then
strProcedureName = InputBox("Procedure?" & vbNewLine & "Leave blank
or cancel to check for module only")
If strProcedureName = "" Then
blnExists = ModuleExists(strModuleName)
Else
blnExists = ProcedureExists(strProcedureName, strModuleName)
End If
MsgBox IIf(blnExists, "Exists", "Not Exists")
End If
End Sub

Rob




.
 

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