Microsoft
Software
Hardware
Network
Question : If folder does not exist, then create one
I use the line of code below in a sub routine that opens Excel from Access and saves it to the file path that I have specified below. On my form Me.txtSubFolder reflects the sub folder that the file is to be saved under.
1:
xlBook.SaveAs FileName:= “C:\MainFolder\” & Me.txtSubFolder & "\FileName.xlsx"
In the event that the folder name, which is stored as a value in Me.txtSubFolder, does not exist; then I need some code that will create the sub folder and name it after the value specified in Me.txtSubFolder.
Any ideas are greatly appreciated. Thanks!
Answer : If folder does not exist, then create one
place this in a REGULAR module
Option Explicit
Public Declare Function MakeSureDirectoryPathExist
s Lib "imagehlp.dll" (ByVal lpPath As String) As Long
---------------------
to use
Call MakeSureDirectoryPathExist
s("C:\Main
Folder\" & Me.txtSubFolder & "\")
this will automatically create the folders if they don't exists.
using this
Call MakeSureDirectoryPathExist
s("c:\a\b\
c\d\e\")
it will create all the folders specified in the line.
NOTE* the last character of the line must be a backslash \
Random Solutions
How can I check for an install new updates for Symantec Backup Exec? I have clicked on the Help drop down menu, but don't see any options for updates
Unable to assign a resource to meeting in Outlook 2010
Excel (2010) Calculate Working Hours Between DateCreated and DateAssigned
Delphi & TWebBrowser issue ???
SQL Server Update Query
"404 - File not found" for Default .aspx on IIS 7.5
File Increasing in Size
Comparison Netgear ReadyNAS vs. Buffalo Terastation
css conditional statements for different browsers AND different resolutions?
Windows Live Messenger XXXX is now friends with YYY