Share via

Visual Basic Regular Expression

Anonymous
2014-09-04T22:38:34+00:00

Hi Guys,

I am using

Mac OS 10.6.8

Microsoft Word for Mac 2011 - Version 14.2.3

I tried to use RegExp (Regular Expression) in VBA. But it shows the compile error "user-defined type not defined"

How to fix this?

Thanks,

Rakesh

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
  1. Anonymous
    2014-09-05T18:37:02+00:00

    VBA does not have a RegExp function. 

    If you are used to using one, it may be on Windows Word, where you can reference the Microsoft VBScript Regular Expressions library and use its RegExp. But that library does not exist on Mac, so you either have to 

     a. find a Mac equivalent (probably shell out and use a command line utility - I have never tried that for regex) or

     b. limit yourself to one of the things available in Word. I think that's either the simple wildcard stuff you get with the VBA Like keyword, or the wilcard pattern matching you get with Word's Find object (which is like regex, but nothing like as powerful as a typical modern regex implementation).

    0 comments No comments
Answer accepted by question author
  1. Anonymous
    2014-09-05T11:37:57+00:00

    Hi Rakesh:

    Word Mac VBA does not include all of the capabilities of VBA.

    RegExp is one of many that VBA on the Mac does not have.  That's why you can't declare it.

    You will need to write alternative string manipulation functions to replace RegExp.

    Hope this helps

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2014-09-04T23:22:31+00:00

    Hi Guys,

    I am using

    Mac OS 10.6.8

    Microsoft Word for Mac 2011 - Version 14.2.3

    I tried to use RegExp (Regular Expression) in VBA. But it shows the compile error "user-defined type not defined"

    How to fix this?

    Thanks,

    Rakesh

    Don't use it! :-)

    What are you trying to do?

    You are also way out-of-date on your Office version. Updating to a the current 14.4.4 version won't help this specific problem but it might help other future problems you might encounter.

    0 comments No comments