Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Adding a folder with code

How do I create a folder, if one does not exist, using VBA in Excel when the
workbook is opened and not create a folder if the specified folder already
exists?
--
Tyrell Fickenscher
Plant Manager / Agronomist
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Adding a folder with code

On Error Resume Next
mkdir "C:\MyFolder"
On Error goto 0

this assumes the existence of only the last folder in the chain is in
question.

--
Regards,
Tom Ogilvy


"Tyrell" wrote in message
...
How do I create a folder, if one does not exist, using VBA in Excel when

the
workbook is opened and not create a folder if the specified folder already
exists?
--
Tyrell Fickenscher
Plant Manager / Agronomist



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default Adding a folder with code

Give this a whirl...

Sub test()
On Error GoTo MakeDirectory
ChDir ("C:\Test2")
On Error GoTo 0

Exit Sub
MakeDirectory:
MkDir "C:\Test2"
Resume Next

End Sub
--
HTH...

Jim Thomlinson


"Tyrell" wrote:

How do I create a folder, if one does not exist, using VBA in Excel when the
workbook is opened and not create a folder if the specified folder already
exists?
--
Tyrell Fickenscher
Plant Manager / Agronomist

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Adding a folder with code

I just try to create it and ignore any error message.

on error resume next
mkdir "C:\myfolder"
on error goto 0



Tyrell wrote:

How do I create a folder, if one does not exist, using VBA in Excel when the
workbook is opened and not create a folder if the specified folder already
exists?
--
Tyrell Fickenscher
Plant Manager / Agronomist


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a file to xlstart folder. Tenacious Excel Discussion (Misc queries) 3 April 6th 09 04:24 AM
Need code to save file to new folder, erase from old folder Ron M. Excel Discussion (Misc queries) 1 February 24th 06 06:02 PM
Adding a folder Momo Excel Programming 2 June 30th 05 02:53 PM
Adding file name and path to to footer of all workbooks in a folder. Muxer[_2_] Excel Programming 2 April 9th 04 08:56 AM
Opening A Folder Using VB Code kiza Excel Programming 2 January 4th 04 11:27 AM


All times are GMT +1. The time now is 11:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"