here my code:
Private Sub CausticSodaExcel()
Dim adoRs As New ADODB.Recordset
Dim exl, xlbook, xlsht
Dim strSQl As String, dteFrom As String, dteTo As String
dteFrom = Format(dtFrom.Value, "mm/dd/yyyy 00:00:00")
dteTo = Format(dtTo.Value, "mm/dd/yyyy 23:59:59")
strSQl = "Select TestDate,Shift,Analyzedby,Reviewedby,DelNo,Quantity,resultpurity,resultSG,passfailpurity,passfailsg" & _
"from qa_wl_CausticSoda where TestDate BETWEEN '" & dteFrom & "' and '" & dteTo & "' order by causticsodaid asc"
OpenRecSet adoRs, strSQl
If Not adoRs.EOF Then
Set exl = CreateObject("Excel.application")
Set xlbook = exl.Workbooks.Open(App.Path & "\Reports\CausticSoda.xlt")
Set xlsht = xlbook.Sheets("data")
xlsht.Activate
xlsht.Cells(9, 1).CopyFromRecordset adoRs
xlsht.Name = "Phase " & phase
xlsht.range("A9:A65536").Select
exl.Selection.NumberFormat = "mmm-dd-yy ;@"
xlsht.Cells(6, 1).Select
exl.Application.Visible = True
Else
MsgBox "No Record Found!", vbInformation
End If
adoRs.Close
End Sub

New Topic/Question
Reply




MultiQuote



|