I'm trying to have a FileDialog select a shortcut (*.lnk) file, and not the destination file in VBA.
E.g. 'C:\MyShortcut.lnk' is a shortcut to 'C:\SomeFolder\BurriedDeep\MyFile.xls' and I want to select the shortcut and update it to 'C:\SomeFolder\BurriedDeep\MyNewFile.xls'
MSDN link about FileDialog:
https://msdn.microsoft.com/en-us/library/office/ff862446.aspx?f=255&MSPPError=-2147217396
Code is:
Dim objFileDialog As FileDialog
Set objFileDialog = Application.FileDialog(msoFileDialogFilePicker)
objFileDialog.AllowMultiSelect = False
objFileDialog.Filters.Add "Shortcuts", "*.lnk", 1
objFileDialog.Show
'User to select file
MsgBox objFileDialog.SelectedItems(1)
However, whenever I select the shortcut, the value returned is the path and name of the destination file, not the shortcut.
From what I can discover, Visual Studio allows the use of a "DereferenceLinks" property to alleviate this problem, but I'm using Excel 2010 VBA and not Visual Studio and I can't find a similar property in VBA.
https://msdn.microsoft.com/en-us/li...ms.filedialog.dereferencelinks(v=vs.110).aspx
Does anyone know of a good workaround?
E.g. 'C:\MyShortcut.lnk' is a shortcut to 'C:\SomeFolder\BurriedDeep\MyFile.xls' and I want to select the shortcut and update it to 'C:\SomeFolder\BurriedDeep\MyNewFile.xls'
MSDN link about FileDialog:
https://msdn.microsoft.com/en-us/library/office/ff862446.aspx?f=255&MSPPError=-2147217396
Code is:
Dim objFileDialog As FileDialog
Set objFileDialog = Application.FileDialog(msoFileDialogFilePicker)
objFileDialog.AllowMultiSelect = False
objFileDialog.Filters.Add "Shortcuts", "*.lnk", 1
objFileDialog.Show
'User to select file
MsgBox objFileDialog.SelectedItems(1)
However, whenever I select the shortcut, the value returned is the path and name of the destination file, not the shortcut.
From what I can discover, Visual Studio allows the use of a "DereferenceLinks" property to alleviate this problem, but I'm using Excel 2010 VBA and not Visual Studio and I can't find a similar property in VBA.
https://msdn.microsoft.com/en-us/li...ms.filedialog.dereferencelinks(v=vs.110).aspx
Does anyone know of a good workaround?