Hi there,
I am wondering if there is anyway to make the following code work on both PC and mac? It works fine on PC, but on mac the BeforeSave and BeforePrint code does not work and the SaveASheet code gets as far as opening and pasting the sheet but then is unable to save automatically.
thanks
Private Sub Workbook_BeforeClose(Cancel As Boolean)
SaveASheet
End Sub
Private Sub Workbook_Open()
Sheets("Open").Activate
End Sub
Sub SaveASheet()
Dim fName As String
Dim myPath As String
Dim sht As Worksheet
#If Mac Then
myPath = "file://localhost/Volumes/DOCUMENTS/3. Design/Supply Orders/Log/"
#Else
myPath = "U:\3. Design\Supply Orders\Log\"
#End If
For Each sht In ThisWorkbook.Worksheets
If (sht.Range("D1").Value <> "") * (sht.Range("g11").Value <> "") Then
fName = myPath & sht.Range("g11").Value & ".xls"
sht.Copy
With ActiveWorkbook
.SaveAs fName
.Close False
End With
End If
Next sht
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If SaveAsUI = True Then
MsgBox "Please use 'Save' to Save this Workbook...", vbCritical, "Your title"
Cancel = True
End If
End Sub
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Range("f13").Value = "Update Register" Then
Cancel = True
MsgBox "You must complete the register before printing"
End If
End Sub
I am wondering if there is anyway to make the following code work on both PC and mac? It works fine on PC, but on mac the BeforeSave and BeforePrint code does not work and the SaveASheet code gets as far as opening and pasting the sheet but then is unable to save automatically.
thanks
Private Sub Workbook_BeforeClose(Cancel As Boolean)
SaveASheet
End Sub
Private Sub Workbook_Open()
Sheets("Open").Activate
End Sub
Sub SaveASheet()
Dim fName As String
Dim myPath As String
Dim sht As Worksheet
#If Mac Then
myPath = "file://localhost/Volumes/DOCUMENTS/3. Design/Supply Orders/Log/"
#Else
myPath = "U:\3. Design\Supply Orders\Log\"
#End If
For Each sht In ThisWorkbook.Worksheets
If (sht.Range("D1").Value <> "") * (sht.Range("g11").Value <> "") Then
fName = myPath & sht.Range("g11").Value & ".xls"
sht.Copy
With ActiveWorkbook
.SaveAs fName
.Close False
End With
End If
Next sht
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If SaveAsUI = True Then
MsgBox "Please use 'Save' to Save this Workbook...", vbCritical, "Your title"
Cancel = True
End If
End Sub
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Range("f13").Value = "Update Register" Then
Cancel = True
MsgBox "You must complete the register before printing"
End If
End Sub