I have a workbook with VBA built in, built in Excel 2016, that is not working on the Mac version of Excel 2016...
Macros are running on the Mac system, this one errors out with the 'could not create PDF file' message that is built into it.
And this one is working for creating a new row of data, but not for replacing existing rows...
Both subs work just fine in regular Excel, but not in the Mac version... any ideas?
Code:
Public Sub GenerateContact()
Dim wsA As Worksheet
Dim wbA As Workbook
Dim strTime As String
Dim strName As String
Dim strPath As String
Dim strClient As String
Dim strFile As String
Dim strPathFile As String
Dim myFile As Variant
On Error GoTo errHandler
Set wbA = ActiveWorkbook
Set wsA = Sheet6
strTime = Format(Now(), "yyyymmdd")
strClient = wsA.Cells(1, 1)
'get active workbook folder, if saved
strPath = wbA.Path
If strPath = "" Then
strPath = Application.DefaultFilePath
End If
strPath = strPath & "\"
'replace any spaces and periods in sheet name
strName = Replace(wsA.Name, " ", "")
strName = Replace(strName, ".", "_")
'create default name
strFile = strClient & "_" & strName & "_" & strTime & ".pdf"
strPathFile = strPath & strFile
myFile = Application.GetSaveAsFilename _
(InitialFileName:=strPathFile, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and FileName to save")
'export to PDF
If myFile <> "False" Then
wsA.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=myFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End If
exitHandler:
Exit Sub
errHandler:
MsgBox "Could not create PDF file"
Resume exitHandler
Macros are running on the Mac system, this one errors out with the 'could not create PDF file' message that is built into it.
Code:
Sub SubmitChanges()
Dim Name As Long
Dim X As Long
Dim Y As Long
With Application
.EnableEvents = False
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
'Create data row for new clients
If IsError(Application.Match(Sheet3.Range("A2").Value, Sheet4.Range("A1:A10000"), 0)) Then
Y = Sheet4.Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row + 1
Sheet4.Cells(Y, 1) = Sheet3.Cells(2, 1)
Sheet4.Cells(Y, 2) = Sheet3.Cells(9, 2)
Sheet4.Cells(Y, 3) = Sheet3.Cells(8, 2)
Sheet4.Cells(Y, 41) = Sheet3.Cells(13, 2)
'Export values for existing clients
Else: X = Application.Match(Sheet3.Range("A2").Value, Sheet4.Range("A1:A10000"), 0)
Sheet4.Cells(X, 1) = Sheet3.Cells(2, 1)
Sheet4.Cells(X, 2) = Sheet3.Cells(9, 2)
Sheet4.Cells(X, 3) = Sheet3.Cells(8, 2)
Sheet4.Cells(X, 41) = Sheet3.Cells(13, 2)
End If
With Application
.EnableEvents = True
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
End Sub
And this one is working for creating a new row of data, but not for replacing existing rows...
Both subs work just fine in regular Excel, but not in the Mac version... any ideas?