Running Excel 2016 on a MAC

richlocus
2StarLounger
Posts: 149
Joined: 03 Oct 2015, 00:30

Running Excel 2016 on a MAC

Post by richlocus »

Hello Hans:
I tried posting this on the Excel Tech forum but with no luck. So here is the post:

I developed a program that uses the File Open dialog box code on Excel 2016 using VBA. When running the same program on a MAC that is "supposed to run VBA", most of it worked.. except the file, open dialog box.

It works great on a windows machine, but fails on the MAC. I even tried the older version of the code.

Here is the most recent format of the open:

Code: Select all

Private Sub FileDialogueOpenCustomModel()
Application.ScreenUpdating = False
Dim dlgOpenFile As FileDialog
Dim strFullFilePathToModel As String

    strFullFilePathToModel = ""
    Set dlgOpenFile = Application.FileDialog(msoFileDialogOpen)
    With dlgOpenFile
        .AllowMultiSelect = False
        .Filters.Clear
        .Filters.Add "Excel 2007-2016 Workbook", "*.xlsx"
        .FilterIndex = 1
        .Title = "Select Custom Model"
        .Show
        If .SelectedItems.Count < 1 Then
            strCancel = "Y"
            Exit Sub
        End If
        strFullFilePathToModel = .SelectedItems(1)
    End With

Workbooks.Open strFullFilePathToModel
strCustomModelFileNameOpenedByUser = ActiveWorkbook.Name
End Sub

Here is the OLDER version of that function, that also fails:
Public Sub OpenFileDialogue()
' ************************************************
' Display a File Open Dialogue Box For The User
' ************************************************
strCancel = "N"
strWorkbookNameAndPath = Application.GetOpenFilename _
    (FileFilter:=strFilt, _
     FilterIndex:=intFilterIndex, _
     Title:=strDialogueFileTitle)
   
' ************************************************
' Exit If No File Selected
' ************************************************
If strWorkbookNameAndPath = "" Then
    MsgBox ("No Filename Selected")
    strCancel = "Y"
    Exit Sub
ElseIf strWorkbookNameAndPath = "False" Then
    MsgBox ("You Clicked The Cancel Button")
    strCancel = "Y"
    Exit Sub
End If

' ******************************************************
' Now That You Have The User Selected File Name, Open It
' ******************************************************

Workbooks.Open strWorkbookNameAndPath
strWorkbookName = ActiveWorkbook.Name
MsgBox ("You Just Opened " & strWorkbookName)
End Sub
Thanks for any information.
Rich Locus

jstevens
GoldLounger
Posts: 2618
Joined: 26 Jan 2010, 16:31
Location: Southern California

Re: Running Excel 2016 on a MAC

Post by jstevens »

Rich,

Ron de Bruin's website is a good resource for MAC related VBA.

Another resource relating to GetOpenFilename Excel 2011.

I hope this helps.
Regards,
John

User avatar
HansV
Administrator
Posts: 78237
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Running Excel 2016 on a MAC

Post by HansV »

John has pointed you to some excellent resources.
Also see Opening files in Excel VBA on a mac
Best wishes,
Hans

richlocus
2StarLounger
Posts: 149
Joined: 03 Oct 2015, 00:30

Re: Running Excel 2016 on a MAC

Post by richlocus »

Thanks Hans!!

richlocus
2StarLounger
Posts: 149
Joined: 03 Oct 2015, 00:30

Re: Running Excel 2016 on a MAC

Post by richlocus »

Thanks John!!