Hi,
I am doing this:
Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If ActiveWorkbook.Path = vbNullString Then
Call xyz_SaveQuote
Cancel = True
End If
End Sub
This works fine on Windows Office, but is totally ignored on Mac Office.
The crux of this is that I offer up a Folder Dialog (Application.FileDialog(msoFileDialogFolderPicker)) but on a Mac we just get the standard Save File dialog.
Sub xyz_SaveQuote()
Call AppSettings(False, xlCalculationManual)
Dim MandatoryCells As Range, Cell As Range
Dim Filename As String
Dim Offset As Integer, i As Integer
Dim Validate As Boolean: Validate = True
Range("$E$1:$G$1").Select
Set MandatoryCells = Range("$E$1,$D$2,$D$3,$D$4,$D$6,$D$7,$D$8,$D$9,$H$2,$H$3,$H$4,$H$6")
For Each Cell In MandatoryCells
With Cell
Offset = .Cells(1, 1).MergeArea.Columns.Count
.Offset(0, 1).ClearContents
If .Style = "Percent" Then
.Offset(0, 1).FormulaR1C1 = "=IF(ISBLANK(RC[-" & Offset & "]),""!"","""")"
If IsEmpty(.Value2) Then Validate = False
Else
.Offset(0, 1).FormulaR1C1 = "=IF(LEN(RC[-" & Offset & "])<5,""!"","""")"
If Len(.Value2) < 5 Then Validate = False
End If
End With
Next Cell
Set MandatoryCells = Nothing
If Validate = False Then GoTo ExitHandler
With Application.FileDialog(msoFileDialogFolderPicker)
If .Show Then
Filename = .SelectedItems(1)
With ActiveWorkbook
With .Worksheets(3)
Call xyz_ToggleGroups(3, True)
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Filename & "\" & .Range("$E$1").Value2 & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
Call xyz_ToggleGroups(3, False)
End With
With .Worksheets(4)
Call xyz_ToggleGroups(4, True)
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Filename & "\" & .Range("$E$1").Value2 & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
Call xyz_ToggleGroups(4, False)
End With
.SaveCopyAs Filename:=Filename & "\" & Worksheets(2).Range("$E$1").Value2 & "-XL.xlsm"
End With
End If
End With
Filename = vbNullString
ExitHandler:
Call AppSettings(True, xlCalculationAutomatic)
Exit Sub
ErrorHandler:
Resume ExitHandler
End Sub
Bookmarks