I have a vba module call runme with this code
I can run it from vb eidit interface by hitting run.
How can I run it from command line?
I tried "msaccess.exe" "C:\Documents and Settings\jzhu\My Documents\test.mdb" /Excl /X "runme"
But it does not seems to work.
THX.
Jeff
Code:
Option Compare Database
Sub makequery()
Dim db As DAO.Database
Dim qry As DAO.QueryDef
Dim rs As DAO.Recordset
Dim fld As DAO.Field
Dim XlApp As Excel.Application
Dim xlwb As Excel.Workbook
Dim xlws As Excel.worksheet
Dim xlrn As Excel.Range
Dim x As Integer
Set db = Access.CurrentDb
Set qry = db.QueryDefs("q1")
Set rs = qry.OpenRecordset
Set XlApp = New Excel.Application
XlApp.Visible = True
Set xlwb = XlApp.Workbooks.Add
Set xlws = xlwb.ActiveSheet
x = 1
For Each fld In rs.Fields
xlws.Cells(1, x).Value = fld.Name
x = x + 1
Next fld
Set xlrng = xlws.Cells(2, 1)
xlrng.CopyFromRecordset rs
xlws.Columns.AutoFit
rs.Close
qry.Close
qry.Close
End Sub
I can run it from vb eidit interface by hitting run.
How can I run it from command line?
I tried "msaccess.exe" "C:\Documents and Settings\jzhu\My Documents\test.mdb" /Excl /X "runme"
But it does not seems to work.
THX.
Jeff