Hi RS,
So I guess it is possible to work around certain code and write it in a way that can be used on both mac and pc. Here is an example of a module I think will trip up, I can't remember exactly which bits fail as I was borrowing a friends mac when I tested it, but I have a feeling this won't work as it is. What can I do to get the same result but use it on a mac as well?
Sub ping(DocFile As String, xFile As String)
Dim nRes
Dim x
Dim xBook As Workbook
Dim ish As Worksheet
Set xBook = ActiveWorkbook
Set ish = xBook.Sheets(2)
With CreateObject("WScript.Shell")
nRes = .Run("%comspec% /c ping.exe -n " & 1 & " -w " & 250 _
& " 192.168.0.5 | find ""TTL="" > nul 2>&1", 0, True)
End With
If nRes <> 0 Then
If ish.Range("DOCTYPE") = "" Then
GoTo REQUEST
ElseIf ish.Range("DOCTYPE") = "REQUEST" Then
GoTo REQUEST
Else
GoTo AUTH
End If
REQUEST:
MsgBox ("Unable to connect to the mail server." & vbNewLine & vbNewLine _
& "Please print off the word document, if you haven't already done so " & vbNewLine _
& "and give it the Authorisor. The file can be found in a folder " & vbNewLine _
& "called 'STAFF CHANGES BACKUP' on your desktop. Alternatively email " & vbNewLine _
& "both the excel file and word document relating to this request to " & vbNewLine _
& "the Authorisor")
'Set WordApp = GetObject(, "word application")
'If Err.Number <> 0 Then 'word isn't running
Set WordApp = CreateObject("word.application")
'End If
'On Error GoTo 0
With WordApp
Set WordDoc = .documents.Open(DocFile)
.Visible = True
End With
GoTo NextStep
AUTH:
MsgBox ("Unable to connect to the mail server." & vbNewLine & vbNewLine _
& "Please print off the word document, if you haven't already done so " & vbNewLine _
& "and give it HR and " & ish.Range("MNAME") & ". The file can be found in a folder " & vbNewLine _
& "called 'STAFF CHANGES BACKUP' on your desktop. Alternatively email " & vbNewLine _
& "both the excel file and word document relating to this request to " & vbNewLine _
& "HR and " & ish.Range("MNAME") & ".")
'Set WordApp = GetObject(, "word application")
'If Err.Number <> 0 Then 'word isn't running
Set WordApp = CreateObject("word.application")
'End If
'On Error GoTo 0
With WordApp
Set WordDoc = .documents.Open(DocFile)
.Visible = True
End With
GoTo NextStep
NextStep:
opdoc: If WordDoc Is Nothing Then
GoTo opdoc
Else
WordApp.Visible = False
x = MsgBox("Would you like to print the change request?", vbQuestion + vbYesNo, "PRINT CHANGE REQUEST")
If x = vbYes Then
WordDoc.PrintOut
Call Utilities.closebk
Exit Sub
Else
Call Utilities.closebk
Exit Sub
End If
End If
Else
FileDoc = DocFile
FileX = xFile
Call Emailer.MAuth(FileDoc, FileX)
Call Utilities.closebk
End If
End Sub
Bookmarks