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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 12:56 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com