Excel VBA poser.

  Chas49 23:05 06 Apr 2010

I would like some help with VBA please.

I want to find out, from within a program that I am writing, if a folder (and one subfolder) exist on the C drive and then, if it doesn't, create them. It's been quite a while since I worked in VBA and I'm afraid this is one of the things I have forgotten. Can't fiknd anything in the VBA pages either, though that is probably my fault!

  robin_x 23:59 06 Apr 2010

I self taught myself VBA enough to make a database.

Question of hunting. I was never really a DOS expert either (making .bat files) but...

I am sure there is an IF EXIST path function somewhere.

Which will return true/false (1/0).

Dunno how to assign it to a variable.

But if it does not exist "mkdir path"

How you do that in nice GUI is also beyond me.

But I am sure it is not difficult.

  Chas49 00:04 07 Apr 2010

robinofloxley: Very helpful, you have jogged my memory - well partly anways 8-). I'll experiment.


  robin_x 00:14 07 Apr 2010

While I love PC Advisor forum, also try digitalspy.co.uk forums Computing and Networks...they love this type of stuff

  Chas49 00:34 07 Apr 2010


Thanks. Tried that but they seem to cover all types of media other than computer programming.
I'll soldier on tomorrow.

Who knows, perhaps VOG will see this tomorrow and offer me his very good advice.

It's late so bed is calling - loudly.

Thanks again.

  KremmenUK 07:11 07 Apr 2010

Not sure about VBA but under VB I would perform the above MKDIR (folder name) and precede it with "On Error Resume Next"

If the folder exists then the error when it tries to build it again will be passed over and if it doesn't exist it will be created.

  Chas49 11:10 07 Apr 2010


This is what I am doing at the moment. robinofloxley's reply jogged my memory and then it was just a matter of experimenting with the code.
Anyway, many thanks for your help. Appreciated.

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

Samsung Galaxy S9 review

Explore Milton Glaser's iconic poster designs from the 1960s to present, including Bob Dylan, I…

What to expect at Apple's 27 March education event

Idées cadeaux pour geeks et tech addicts