G
Guest
I don't know how to create a directory?
I have a syntax error on the createFile line and I am trying to create the
excel file if it doesn't exist. This is urgent.
If you can help, thanks in advance. Janis
----------code-----------
Private Sub Form_AfterUpdate()
Const STRPATH = "c:\Test"
Const STRFILENAME = "Emp.xls"
Const OPEN_EXISTING = 3&
If Dir(STRPATH) = "" Then
' Create directory
Else
If STRPATH & "\" & STRFILENAME = "" Then
CreateFile(strPath, 0, 0, ByVal 0&, OPEN_EXISTING, 0, ByVal 0&)
Me.xlsOutput.worksheets ("Emp.xls")
End If
End Sub
Private Declare Function CreateFile& Lib "kernel32" Alias "CreateFileA"
(ByVal _
lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode
As Long, _
lpSecurityAttributes As Any, ByVal dwCreationDisposition As Long, _
ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long)
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long)
As Long
I have a syntax error on the createFile line and I am trying to create the
excel file if it doesn't exist. This is urgent.
If you can help, thanks in advance. Janis
----------code-----------
Private Sub Form_AfterUpdate()
Const STRPATH = "c:\Test"
Const STRFILENAME = "Emp.xls"
Const OPEN_EXISTING = 3&
If Dir(STRPATH) = "" Then
' Create directory
Else
If STRPATH & "\" & STRFILENAME = "" Then
CreateFile(strPath, 0, 0, ByVal 0&, OPEN_EXISTING, 0, ByVal 0&)
Me.xlsOutput.worksheets ("Emp.xls")
End If
End Sub
Private Declare Function CreateFile& Lib "kernel32" Alias "CreateFileA"
(ByVal _
lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode
As Long, _
lpSecurityAttributes As Any, ByVal dwCreationDisposition As Long, _
ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long)
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long)
As Long