PDA

View Full Version : Excel 2016 VBA on MAC to Open A File



richlocus
03-18-2021, 09:26 PM
Hello:
I developed an application using Microsoft Excel 2016 that uses a File Open Dialog Box (the user navigates to the file they want to open, and selects the file). The VBA code does not work on a MAC Excel 2016 (most other code is compatible).

Here is code that works on a Windows system to select and open a file:
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

Unfortunately, I can't seem to find a similar function for Excel 2016 on a MAC.

Any ideas?

Thanks,
Rich Locus