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?
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?