Hi Sorry for the confusion....
here's the code..
----------------------------------------------
Function LeadsToExcel(dbPath As String, BasePath As String, qryName As
String, docName As String) '
Dim ojXls As Excel.Application
Dim xlDoc As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim mySQL As String
Dim myCon As String
On Error GoTo Err_Reset
Set ojXls = New Excel.Application
Set xlDoc = ojXls.Workbooks.Add
Set xlSheet = xlDoc.Worksheets.Item(1)
With xlSheet.QueryTables.Add(Connection:=Array(Array( _
"ODBC;DSN=MS Access 97 Database;DBQ=" & dbPath & ";" _
), Array( _
"DefaultDir=\\Server\Path;" _
), Array("DriverId=281;FIL=MS
Access;MaxBufferSize=2048;PageTimeout=5;")), _
Destination:=xlSheet.Range("A1"))
.SQL = Array( _
"SELECT * " & Chr(13) & "" & Chr(10) & "FROM `" & qryName & "` `" &
qryName & "`")
.FieldNames = True
.RefreshStyle = xlInsertDeleteCells
.RowNumbers = False
.FillAdjacentFormulas = False
.RefreshOnFileOpen = False
.HasAutoFormat = True
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.refresh BackgroundQuery:=False
.SavePassword = True
.SaveData = False
.Delete
End With
On Error Resume Next
Kill BasePath & "\Path\" & docName & ".xls"
ChDir BasePath & "\Path\"
ojXls.ActiveWorkbook.SaveAs FileName:=BasePath & "\Path\" & docName &
".xls", FileFormat:=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False, CreateBackup:=False
ChDir "\\Server\Path"
ojXls.ActiveWorkbook.SaveAs FileName:="Server\Path\" & docName & ".xls",
FileFormat:=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False, CreateBackup:=False
xlDoc.Close
ojXls.Quit
Set xlSheet = Nothing
Set xlDoc = Nothing
Set ojXls = Nothing
Exit Function
Err_Reset:
Set xlSheet = Nothing
Set xlDoc = Nothing
Set ojXls = Nothing
MsgBox "Excel Error: " & Err.Number & " - " & Err.Description
End Function
----------------------------------------------------------------------------
--
any ideas..?
Thanks
Jado