Have you tried getting the name from the object that contains the class or procedure? For example if the procedure is in say sheet1 of an excel workbook, you could get the name by drilling down in the sheet1 object.
Hope that helps get you going in a positive direction.
Last Wiki Answer Submitted: October 21, 2004 11:13 am by Jnbutler0 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
Not quite sure what you are trying to accomplish here, but this script will loop through all of the VBE Objects in your workbook project, and then reads in the name of the module if it has any code in it.
Sub countModules()
Dim modCount As Integer
Dim modName As String
Dim codeCount As Integer
modCount = ThisWorkbook.VBProject.VBComponents.Count
For a = 1 To modCount
codeCount = ThisWorkbook.VBProject.VBComponents(a).CodeModule.CountOfLines
If codeCount > 0 Then
modName = ThisWorkbook.VBProject.VBComponents(a).Name
End If
Next a
End Sub
If you need to know more about the modules, you should use the CodeModule object (you need to install the VBA add-in Object Model), which allows you to modify code dynamically.
If you just want to get the name of the module/object that is active, use the SelectedVBComponent property.
Not quite sure what you are trying to accomplish here, but this script will loop through all of the VBE Objects in your workbook project, and then reads in the name of the module if it has any code in it.
Sub countModules()
Dim modCount As Integer
Dim modName As String
Dim codeCount As Integer
modCount = ThisWorkbook.VBProject.VBComponents.Count
For a = 1 To modCount
codeCount = ThisWorkbook.VBProject.VBComponents(a).CodeModule.CountOfLines
If codeCount > 0 Then
modName = ThisWorkbook.VBProject.VBComponents(a).Name
End If
Next a
End Sub
If you need to know more about the modules, you should use the CodeModule object (you need to install the VBA add-in Object Model), which allows you to modify code dynamically.
If you just want to get the name of the module/object that is active, use the SelectedVBComponent property.
Darryn
Thanks for the info. However, the code is not written behind a Spreadsheet but is instead compiled into a dll.
Matt