I have an addin needing to set the drive where the back-up to be done. It should be an external media (HD or memory stick). I know how to identify/check if it is external media and I have the next function in order to Browse for a folder:
It works well returning the drive letter even if a folder on that drive is selected. What I will like to improve is to set the start directory in MyComputer (to set InitialFileName = 'MyComputer', or change CurDir for 'MyComputer') in order to see only drives. Since, sometimes when I browse for a folder this thing happens I suppose it can be set but I downt know how...
Can anybody help on that issue?
Thanks in advance!
Code:
Function GetDrive() As Variant
Dim fldr As FileDialog
Dim vItem As Variant
Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
With fldr
.Title = "Select the drive for back-up!"
.AllowMultiSelect = False
.InitialFileName = "" 'Here I think should set MyComputer if I would know how...
If .Show <> -1 Then GoTo NextCode
vItem = .SelectedItems(1)
End With
NextCode:
GetDrive = Left(vItem, 3)
Set fldr = Nothing
End Function
Can anybody help on that issue?
Thanks in advance!