View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Why CreateObject("vbscript.regexp") doesn't work?


If you have a reference set to the Regular Expressions library, you
don't need to use CreateObject. Just use the RegEx members as if they
were native VBA code. For example,

Dim RegEx As RegExp

You can also prefix the object name with the library name. I usually
do this for clarity and self-documentation but it usually isn't
necessary:

Dim RegEx As VBScript_RegExp_55.RegExp

This won't show up in the Project window because you are referencing
an COM DLL, not a workbook or XLA add-in. Only workbooks (and xla
add-ins are just workbooks) show up in the Project window.

You don't need to know the file name because you don't open the file.
The file is opened by VBA behind the scenes when necessary. If you
really want to know the file, enter the following in the Immediate
window and press ENTER:

?ThisWorkbook.VBProject.References("VBScript_RegEx p_55").FullPath

This will give you the file name, but there isn't anything you can do
with it.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com




On Thu, 15 Apr 2010 11:34:54 -0700, "Joe User" <joeu2004 wrote:

I get a runtime error ("object variable not set") pointing to the assignment
statement when I do the following:

Dim v As Object
v = CreateObject("vbscript.regexp")

I have select Microsoft VBScript Regular Expressions 5.5 (also tried 1.0)
under Tools References.

But nothing is added under VBAProject \ References in the Project pane, as
there is when I select atpvbaen.xls for example.

Is that indicative of the root cause of the problem, perhaps a missing file?

What is the name of the file that contains the Microsoft VBScript Regular
Expressions 5.5 library?