PDA

View Full Version : regular expressions on a Macintosh



dlh
09-09-2008, 10:31 PM
I've developed code on Excel 2007 for Windows, but I need to port it to a Macintosh. The following piece of code works fine on the PC but breaks on the Mac:


Function IsValidString(S As String) As Boolean
'must start w/ non-zero integer
'may end w/ alphabet characters
'may be one hyphen among alphabet characters, but not @ end
Dim RegExp As Object
Set RegExp = CreateObject("vbscript.RegExp")
RegExp.Pattern = "^(\d*[1-9]+\d*)((-[a-zA-Z]+)|[a-zA-Z]*|([a-zA-Z]+-[a-zA-Z]+))$"
IsValidString = RegExp.test(S)
Set RegExp = Nothing
End Function



And the error message is something like: Cannot Create ActiveX object. I'm unfamiliar with the Macintosh environment, but it sounds like "vbscript.RegExp" is not recognized. Can anyone suggest what is wrong and how to fix it?

shamsam1
09-09-2008, 11:44 PM
try to add reference

"Microsoft visual basic for application extensibility 5.3"

Bob Phillips
09-10-2008, 12:48 AM
Regular Expressions generally comes built-in to IE, and isn't there on the Mac as I understand.

You will need to see if your machine has a file called VBScript.dll and set a reference to that if so.