X
xz739
i have created a excel workbook in vb,below are the codes:
private sub report ()
Dim sfilename As String
Dim spath As String
Dim dtecurrent As Date
Dim msexcel As Object
dtecurrent = Now
Set msexcel = CreateObject("Excel.Application")
With msexcel
..Visible = False
..Workbooks.Open "d:\DYNAMICS\PDB\RPT.xls", , False
End With
With msexcel.Application
..ActiveWorkbook.ActiveSheet.Select
..Cells(2, 1) = Time
..Cells(2, 2) = Date
End With
sfilename = Format(dtecurrent, "mmddyyyy HHMMSS") & ".xls"
spath = System.BasePath & "\htrdata\" & sfilename
msexcel.ActiveWorkbook.SaveAs spath 'Saves the file with the path
msexcel.Visible = True
Set msexcel = Nothing
end sub
*********
in the program i call the function period,because the excel run in
background,so the problem is every time it will add a windows process,
how can i close the process in the function?
private sub report ()
Dim sfilename As String
Dim spath As String
Dim dtecurrent As Date
Dim msexcel As Object
dtecurrent = Now
Set msexcel = CreateObject("Excel.Application")
With msexcel
..Visible = False
..Workbooks.Open "d:\DYNAMICS\PDB\RPT.xls", , False
End With
With msexcel.Application
..ActiveWorkbook.ActiveSheet.Select
..Cells(2, 1) = Time
..Cells(2, 2) = Date
End With
sfilename = Format(dtecurrent, "mmddyyyy HHMMSS") & ".xls"
spath = System.BasePath & "\htrdata\" & sfilename
msexcel.ActiveWorkbook.SaveAs spath 'Saves the file with the path
msexcel.Visible = True
Set msexcel = Nothing
end sub
*********
in the program i call the function period,because the excel run in
background,so the problem is every time it will add a windows process,
how can i close the process in the function?