syntax error creating an excel file

G

Guest

I have a couple questions: First, there is a syntax error on the createFile
line???? What I want to do is create an Excel file.
The second question is how do you create a directory?
Please help
Thanks,
Janis
--------------code---------------
Option Compare Database
Option Explicit




Private Sub Form_AfterUpdate()
strPath = "c:\Test"
strFileName = "Emp.xls"
If Dir(strPath) = "" Then
' Create directory

Else
If strPath & "\" & strFileName = "" Then
'Create spreadsheet

CreateFile(strPath, 0, 0, ByVal 0&, OPEN_EXISTING, 0, ByVal 0&)
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top