Conversion to Mac issue with VBA

jwarren73

New Member
Joined
Jan 22, 2015
Messages
37
I have a workbook with VBA built in, built in Excel 2016, that is not working on the Mac version of Excel 2016...

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?
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
PC and MAC versions of excel are different, maybe you could record the same action in MAC and look at the code
 
Upvote 0
To start with you need to change
Code:
strPath = strPath & "\"
to
Code:
strPath = strPath & Application.PathSeparator
 
Upvote 0
To start with you need to change
Code:
strPath = strPath & "\"
to
Code:
strPath = strPath & Application.PathSeparator


Ahhhh that makes sense because of the different file/folder structure on Macs.. unfortunately I don't have a Mac to test it out on.
 
Upvote 0
beyond the file paths, parts of the system aren't implemented, there are guides on the web
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top