View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.office.developer.vba
Jonathan West Jonathan West is offline
external usenet poster
 
Posts: 13
Default Excel VBA: Browse For Folder - Cancel Button

Hi Rob,

Which version of Office are you using? If XP or later, you can use the
FileDialog object to browse for a folder.

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

"Rob" wrote in message
oups.com...
Dear All

I'm afraid I have another question on this highly active topic. I am
using some code that I found here on Google Groups, a bit of John
Walkenbach's work I think. Any way, the code results in a Browse for
folder dialogue box with three buttons... Make New Folder, OK and
Cancel. My problem lies with the Cancel button, when pressed the macro
hangs, most likely for the following reason...

I use the string (folder path) to open three files in that directory.
When the macro is debugged and I pause the mouse pointer over the
string variable, it shows a row of squares too long to fit in the tool
tips box (presumably, the font isn't available to show what it really
is). Hence, it is trying to open a non-existent file path.

What I would like to do is add a line saying "If (string) = (whatever
'Cancel' returns) Then GoTo Cancelled:" before the string is
used.

I have tried the following remedies (none of which has worked)
- Putting the string in a cell so I can read it (it comes out blank).
- Putting If (string) = "" ...
- Putting If (string) = Null ...
- Etc etc...

For full details of the code, just ask (I'd like to resist cluttering
up the screen for as long as possible, and I barely understand the code
I have copied anyway!)

Many thanks

Rob