3

I am attempting to use the FileDialog object to return a filepath of a picture on a phone (this has also caused problems with a digital camera), connected via USB.

The simplified example is:

Sub filePathFromPhone()

    Dim fd As FileDialog
    Set fd = Application.FileDialog(msoFileDialogFilePicker)

    With fd

        If .Show = -1 Then

            'this prints "Computer" instead of "Computer\XT1031\Internal storage\Pictures\Screenshots\Screenshot_2014-05-22-11-41-41.png"
            Debug.Print .SelectedItems(1)


        End If
    End With

End Sub

This occurs when I navigate to a screenshot on the phone through the dialog and select it. I need this to do some other processing on the file (omitted from above).

The above code works correctly if I pick anything which has a named drive (ie from the C: or D: or network paths with \\path\to\file). Only when I attach a device which becomes mapped via Computer\ paths does the FileDialog not return the full path.

  • How can I return the full filepath from a USB device in VBA?
enderland
  • 13,825
  • 17
  • 98
  • 152
  • tried with my usb storage worked perfectly. by the way where you are using vba? Inside excel or word or where? – ZAT Nov 03 '14 at 19:24
  • @ZAT are you using a camera/phone - it works fine for any drive which maps to a drive name (like an external harddrive). This problem happens in Access/Excel 2010. – enderland Nov 03 '14 at 19:25
  • your device maps to what? Is it not attached as mass storage device or what? – ZAT Nov 03 '14 at 19:26
  • @ZAT If a device, such as a USB storage device, is attached it often is a named drive. For example `B:` drive. These work fine. I am able to open the file directly by copying the path above into explorer (the picture opens). – enderland Nov 03 '14 at 19:32
  • 3
    @ZAT none of your links are relevant to my question. Can you please stop cluttering this? If you don't know how to resolve `How can I return the full filepath from a USB device in VBA?` then please do not continue to comment with irrelevant links. Thanks. – enderland Nov 04 '14 at 14:14
  • just tried to help but links got piled up and problem remains. Sorry for that. All link comments deleted. Perhaps someone with relevant knowledge can help you. – ZAT Nov 05 '14 at 07:27
  • It is unlikely that `FileDialog` will cope with paths coming from a [shell namespace handler](https://stackoverflow.com/a/39223459/11683). – GSerg Nov 28 '18 at 13:02

0 Answers0