run time error #75, path/file error

G

Guest

On the first run through this sub the mkDir command makes the c:\Test
directory. The second time I test the sub it stops in debug mode on the
mkDir line.
tia,


Private Sub Form_AfterUpdate()


'*******************************************************************
'Purpose: To update an Excel spreadsheet with each subsequent record
'*******************************************************************



Const STR_DIRECTORY_PATH = "C:\Test\"
Const STR_Filename = "emp.xls"

Dim lngLastError As Long
Dim appExcel As Excel.Application
Dim wbk As Excel.Workbook
Dim wks As Excel.Worksheet
Dim EndRow As Long

Dim dbs As DAO.Database
Dim rst As DAO.Recordset


'Check if directory exists if not create it

If Dir(STR_DIRECTORY_PATH) = "" Then
MkDir STR_DIRECTORY_PATH
End If


Set appExcel = Excel.Application
appExcel.Visible = True
Set wbk = appExcel.Workbooks.Open("emp.xls")

Set wks = appExcel.Worksheets("Employees")
wks.Activate

EndRow = Range("A65536").End(xlUp).Select

Range("a1").Offset(0, EndRow + 1).Value = Forms![frmEmployees]!Form![ID]
Range("a2").Offset(0, EndRow + 1).Value =
Forms![frmEmployees]!Form![FirstName]
Range("a3").Offset(0, EndRow + 1).Value = Forms![frmEmployees]!Form![Salary]


Set dbs = Nothing
End Sub
 

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