![]() |
Creating folders with VB
Mornin' all!
I've got the following code: Dim WebName As String, SaveFolder As String ActiveDocument.Refresh SaveFolder = "\\web1a\PIBReports\BCA\" & WebName & "\" WebName = ReplaceChars(ActiveDocument.Name, " ", "_") CreatePDF SaveFolder, WebName & ".pdf" CreatePDF SaveFolder, WebName & "_" & ReplaceChars(Left (Now, 10), "/", "-") & ".pdf" What I want, is that if the SaveFolder path doesn't exist, for the script to create all the folders that don't exist. The problem is, I don't know how! Please help! Cheers, Foss |
Creating folders with VB
Hi Foss
In its simplest form: Sub test() On Error Resume Next MkDir ("C:\Temp\Automade") End Sub If the folder exists already, it errs, which the On Error statement takes care of. But it needs C:\Temp to exist, it can do only one level. -- HTH. Best wishes Harald Followup to newsgroup only please "Foss" skrev i melding ... Mornin' all! I've got the following code: Dim WebName As String, SaveFolder As String ActiveDocument.Refresh SaveFolder = "\\web1a\PIBReports\BCA\" & WebName & "\" WebName = ReplaceChars(ActiveDocument.Name, " ", "_") CreatePDF SaveFolder, WebName & ".pdf" CreatePDF SaveFolder, WebName & "_" & ReplaceChars(Left (Now, 10), "/", "-") & ".pdf" What I want, is that if the SaveFolder path doesn't exist, for the script to create all the folders that don't exist. The problem is, I don't know how! Please help! Cheers, Foss |
Creating folders with VB
Thanks very much Harald, that'll do nicely!
-----Original Message----- Hi Foss In its simplest form: Sub test() On Error Resume Next MkDir ("C:\Temp\Automade") End Sub If the folder exists already, it errs, which the On Error statement takes care of. But it needs C:\Temp to exist, it can do only one level. -- HTH. Best wishes Harald Followup to newsgroup only please "Foss" skrev i melding ... Mornin' all! I've got the following code: Dim WebName As String, SaveFolder As String ActiveDocument.Refresh SaveFolder = "\\web1a\PIBReports\BCA\" & WebName & "\" WebName = ReplaceChars(ActiveDocument.Name, " ", "_") CreatePDF SaveFolder, WebName & ".pdf" CreatePDF SaveFolder, WebName & "_" & ReplaceChars(Left (Now, 10), "/", "-") & ".pdf" What I want, is that if the SaveFolder path doesn't exist, for the script to create all the folders that don't exist. The problem is, I don't know how! Please help! Cheers, Foss . |
All times are GMT +1. The time now is 05:09 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com