Choose file with BrowseForFolder with Shell.Application object

Started by erezpaz, June 20, 2016, 12:07:46 AM

Previous topic - Next topic

erezpaz

Hi

I am trying to use com object Shell.Application to open BrowseForFolder and choose a file path as string.
I get exception error each time. Choosing a folder work fine but not a file. Can you help?

oShell = ObjectOpen("Shell.Application")

handle=oShell.BrowseForFolder(0, "Choose a file:","&H1000", "c:\") ;Work Fine
handle2=oShell.BrowseForFolder(0, "Choose a file:","&H4038", "c:\") ;Get exception error

ObjectClose(oShell)

Thanks
Erez

td

The third parameter of the BrowseForFolder method is documented as an integer and not a string.  You need to convert the flag parameter's hex value to a decimal number when passing it to the method.

https://msdn.microsoft.com/en-us/library/windows/desktop/bb774065(v=vs.85).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

erezpaz

Hi

I did it:

a=int("16440")

objFolder=oShell.BrowseForFolder(0, "Choose a file:",a, "c:\")

I still get an exception? What I am doing wrong?

td

It could be anyone of a number of errors.  One possibility is that your iOptions value is incorrect.  You seem to be telling the shell to call a callback function when an invalid name is typed into the edit box but I don't believe that COM Automation directly supports using that option.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade