
4,391 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
how to run Application.FileDialog(msoFileDialogOpen) vba code in mac office 365 when i run on windows it works perfect but on mac it shows error 91 block variable not set. my code is under. can you help me
sub aaa()
Dim myFileDialog As Office.FileDialog
Set myFileDialog = Application.FileDialog(msoFileDialogOpen)
myFileDialog.AllowMultiSelect = False
myFileDialog.Title = " Select a Bank Statement file to open "
If myFileDialog.Show = -1 Then
'Get the file name and path
fna = myFileDialog.SelectedItems(1)
'Open the file
Set wb = Workbooks.Open(fna)
Else
MsgBox " You chose to quit"
Exit Sub
End If
msgbox wb.Sheets(1).Range("D3").value
end sub
To open built-in dialogs in Office for Mac VBA, you'll have to use the MacScript command. Please see the answer on this page for an example: https://answers.microsoft.com/en-us/msoffice/forum/all/showing-dialogs-word-for-mac-vba/513ea974-378d-4ebe-95c3-a0221a9287ff