Consulting

Results 1 to 2 of 2

Thread: Word Macro not run in Mac

  1. #1
    VBAX Contributor
    Joined
    May 2010
    Posts
    107
    Location

    Word Macro not run in Mac

    Hi,


    I am using Mac OS X, Version 10.6.8, Office for Mac 2011

    The below macro Works in Windows PC and not work in Mac and shows the following error in the below 2 lines

    Compile error:
    wrong number of arguments or Invalid property assignment

    InString = replace(InString, Delims(Ndx) & Delims(Ndx), Delims(Ndx))
      
      InString = replace(InString, Delims(Ndx), Chr(1))
    Is there any command equal to the replace command

    Function SplitEx(ByVal InString As String, IgnoreDoubleDelmiters As Boolean, _
            ParamArray Delims() As Variant) As String()
        Dim Arr() As String
        Dim Ndx As Long
        Dim N As Long
    
        If Len(InString) = 0 Then
            SplitEx = Arr
            Exit Function
        End If
        If IgnoreDoubleDelmiters = True Then
            For Ndx = LBound(Delims) To UBound(Delims)
                N = InStr(1, InString, Delims(Ndx) & Delims(Ndx), vbTextCompare)
                Do Until N = 0
    
                    InString = replace(InString, Delims(Ndx) & Delims(Ndx), Delims(Ndx))
                    N = InStr(1, InString, Delims(Ndx) & Delims(Ndx), vbTextCompare)
                Loop
            Next Ndx
        End If
    
    
        ReDim Arr(1 To Len(InString))
        For Ndx = LBound(Delims) To UBound(Delims)
           InString = replace(InString, Delims(Ndx), Chr(1))
        Next Ndx
        Arr = split(InString, Chr(1))
        SplitEx = Arr
    End Function
    
    'This allows mutiple delimiters of different lenghts. For example, to split on |, :: and ,, you would call the function like
    
    Sub AAA()
        Dim S As String
        Dim T() As String
        Dim N As Long
        S = "this||is some::delimited,text"
        T = SplitEx(S, True, "||", "::", ",")
        For N = LBound(T) To UBound(T)
            Debug.Print N, T(N)
        Next N
    End Sub
    Thanks,
    Rakeshh

  2. #2
    VBAX Newbie
    Joined
    Dec 2014
    Posts
    1
    Location
    Hi Rakesh,
    I had the same issue with the function Mid in Office for Mac 2011, and I solved it by prepending "VBA." to the function.

    So in your code you can try this:

    InString = VBA.replace(InString, Delims(Ndx) & Delims(Ndx), Delims(Ndx))
    
    InString = VBA.replace(InString, Delims(Ndx), Chr(1))
    Maybe you also need to add the "VBA." prefix to other members or constants defined in the VBA library, like 'vbTextCompare'.

    Hope it works for your issue.
    Cheers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •