mccaskey said:
Can anyone point me to documentation on the differences between VBA
for Word on a Mac and on Windows? I'm coding with Word 2003 on XP and
am told I can't use functions such as split() and mid() if I want my
template to work on a Mac.
True?
More importantly, where can I find such info? I've failed so far. For
example, I can't find a VBA on Mac Language Reference on
www.microsoft.com.
Take a look at these topics in Mac Word/VBA help:
"Strategies for Developing Cross-Platform Solutions"
"Differences between Word VBA for Windows and Word
VBA for the Macintosh"
Couple of key points:
All Mac VBA versions are 5.00, so you can't use functions introduced in
VBA6, like split(), though you can use mid(), which is a VBA5 function.
On my cross-platform applications, I include a module containing VBA5
equivalents for VB6 commmands, along with conditional compilation. For
instance:
#If Mac Then
Public Function Split( _
ByVal sInput As String, _
Optional ByVal sDelimiter As String, _
Optional ByVal nLimit As Long = -1, _
Optional ByVal bCompare As Integer = vbBinaryCompare _
) As Variant
Dim nCount As Long
Dim nPos As Long
Dim nDelimiterLength As Long
Dim nStart As Long
Dim sOutput() As String
If nLimit = 0 Then
Split = Array()
Else
nDelimiterLength = Len(sDelimiter)
If nDelimiterLength = 0 Then
Split = Array(sInput)
Else
ReDim sOutput(0 To Len(sInput))
nStart = 1
nPos = InStr(nStart, sInput, sDelimiter, bCompare)
Do While (nPos > 0) And (nCount <> nLimit - 1)
sOutput(nCount) = Mid(sInput, nStart, nPos - nStart)
nStart = nPos + nDelimiterLength
nCount = nCount + 1
nPos = InStr(nStart, sInput, sDelimiter, bCompare)
Loop
sOutput(nCount) = Mid(sInput, nStart)
ReDim Preserve sOutput(0 To nCount)
Split = sOutput
End If
End If
End Function
#End If