View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Peter T[_7_] Peter T[_7_] is offline
external usenet poster
 
Posts: 162
Default User-defined type not defined


"Walter Briscoe" wrote in message
...
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
'
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"?
I mentioned "Windows Scripting Secrets" code which enumerates all
typelibs. I am looking for VBA code with the same capability.
--
Walter Briscoe


Bit confused with what you're doing and why.

First, you say you set the reference, can you see in object browser (ensure
your file is selected), if it is you should see RegExp listed in Classes. If
it's not there what are you using Win64, if so is your Office default 32 or
64 bit. Either way, if you are in Win64 did you set the correct reference
for your office version.

Not sure if related but FWIW there were some recent vbscript updates
recently, typically for security reasons but they sometimes cause problems.
If it was working but nothing has changed in your setup try rolling back.

Second, I don't follow the rest of what you say, "with the same
capability" - do to what?

I agree with Garry, develop with Early Binding, then adapt and distribute
with Late Binding for a better chance of finding it in different setups.

Peter T