View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
GS[_6_] GS[_6_] is offline
external usenet poster
 
Posts: 1,182
Default User-defined type not defined

In message of Tue, 29 Nov 2016 14:40:03
in microsoft.public.excel.programming, GS writes
Better help if you show the offending code!


Garry,
I DID show offending code.
I will try again.
I have just recorded and edited the following code:

Option Explicit

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 30/11/2016 by IBM
'
Dim RE As Regexp


Regexp by itself is not defined, nor is it fully qualified. This
compiles without error for me in xl2003...

Option Explicit

Sub test()
Dim re As regexp

End Sub

...where I have ToolsReferences... set for the lib.
'
End Sub

When compiled, it gets
Compile error
User-defined type not defined

I happen to "know" the way to deal with this is to add a reference to
Microsoft Vbscript Regular Expressions 1.0 or 5.5.
How would I find that out, if I did not have that "knowledge"?


That's part of the VBA developer's skill set; -knowing what to do and
how to do it!

If you add a ref to the VBScript Regular Expressions object lib then
you'll be 'early binding' your project. This is fine for project dev
but is always better, IMO, to use late binding for runtime...

Option Explicit

Sub test2()
Dim re
Set re = CreateObject("VBScript.Regexp")

End Sub

...which also compiles without error.

I mentioned "Windows Scripting Secrets" code which enumerates all
typelibs. I am looking for VBA code with the same capability.


Perhaps this is what the References dialog does?! Surely the code in
that book can be translated to VB same as other VBScript can...

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion