Menu
Is there a universal OS variant of this? I am looking to have this code work on a Mac and PC, but this seems only to work on a PC. StrFile = Application.GetOpenFilename('Text Files (.csv).csv', '.
Hi
I'm new in the forum and trying to learn VBA. I got this great code from a member here and I forgot to mention that I'm using Excel for Mac 2011.
When I try to run the macro, I get an error on the line in red in the code below. I did a research for the error and found the following:
'On a Mac, the filefilter is not working and it is not possible to select more than one file.
Also, ChDir is not working like in Windows to set the folder that will open with GetOpenFilename. But we can use a combination of VBA and Applescript.'
Does anybody knows how to fix it? Below, it's part of the code.
Thanks,
-----------------------------------
I am trying to use the GetOpenFileName function for a network folder location.
I understand that I need to use the ChDrive function in order to nominate a folder on a network drive. However I may not know the network drive as the pathname to search is entered by the user (using the SHBrowseForFolder function). They may traverse to the network folder from My Network Places and thus the first character of the path would not be the drive letter.
I have the code below, but it doesnt work in the above instance
Any suggestions on how to resolve this would be appreciated (besides forcing the user to enter a path from the network drive letter).
Cheers
Greg
If Not ((UCase(Mid(DataWorkbook.path, 1, 1)) < 'A') Or _
(UCase(Mid(DataWorkbook.path, 1, 1)) > 'Z')) Then
ChDrive (Mid(DataWorkbook.path, 1, 1))
End If
ChDir (DataWorkbook.path)
ImportFilename = Application.GetOpenFilename(FileFilter:='microsoft excel files (*.xls), *.xls', _
Title:='Select File', MultiSelect:=False)