Hi All and TIA,
I'm trying to use VBA to launch a file picker and save the file name that the user selects in a certain cell (on a Mac - msoFileDialogFilePicker isn't compatible). I managed to do this with the file path using the code below. However, I found the MacScript command on google and can't figure out how to edit it to store the file name instead of the file path. Any suggestions? Thanks again!!!
I'm trying to use VBA to launch a file picker and save the file name that the user selects in a certain cell (on a Mac - msoFileDialogFilePicker isn't compatible). I managed to do this with the file path using the code below. However, I found the MacScript command on google and can't figure out how to edit it to store the file name instead of the file path. Any suggestions? Thanks again!!!
VBA Code:
Sub AddWordTemplate()
Dim FirstRow As Long
Dim folderPath As String
Dim RootFolder As String
Dim scriptstr As String
FirstRow = Sheet2.Range("F99999").End(xlUp).Row + 1
RootFolder = MacScript("return (path to desktop folder) as String")
scriptstr = "(choose file with prompt ""Select the file""" & " default location alias """ & RootFolder & """) as string"
folderPath = MacScript(scriptstr)
Sheet2.Range("F" & FirstRow).Value = folderPath
End Sub