OWorksheet.Cells(iRowCount, 6).Value = drSystem("weight") OWorksheet.Cells(iRowCount, 5).Value = drSystem("railcar_number") OWorksheet.Cells(iRowCount, 4).Value = drSystem("customer_purchase_order_no") OWorksheet.Cells(iRowCount, 3).Value = drSystem("invoice_number")
OWorksheet.Cells(iRowCount, 2).Value = drSystem("customer_no") OWorksheet.Cells(iRowCount, 1).Value = drSystem("ship_date")
SSQL += "WHERE i.ship_date BETWEEN N'" & Format(Me.dtpStartDate.Value, "MM/dd/yyyy") & "' AND N'" & Format(Me.dtpEndDate.Value, "MM/dd/yyyy") & "' AND "ĭrSystem = modGeneral.drRunSQL(sSQL, CommandType.Text) SSQL += "ON i.invoice_number = r.invoice_number " SSQL += "i.member + N'-' + i.member_purchase_order_no AS member_purchase_order_no " SSQL = "SELECT FORMAT(i.ship_date, N'MM/dd/yyyy') AS ship_date, " OWorksheet.Cells(1, 8).Value = "Member purchase order" OWorksheet.Cells(1, 4).Value = "Purchase order" OWorksheet.Cells(1, 2).Value = "Customer" OWorksheet.Cells(1, 1).Value = "Ship date" MsgBox("Select A, B or both before continuing.", vbInformation) If Not Me.chkA.Checked And Not Me.chkB.Checked Then
Task coach export to invoice full#
I have included the full code for this below: Private Sub btnExport_Click(sender As Object, e As EventArgs) Handles btnExport.Clickĭim oExcel As Excel.Application = Nothingĭim drSystem As SqlClient.SqlDataReader = Nothing If a user ticks chkA the clean-up code does NOT work. The code to create each workbook is identical except for the SQL. However, my code is creating two workbooks. ReleaseComObject(oExcel) : oExcel = Nothing ReleaseComObject(oWorkbook) : oWorkbook = Nothing ReleaseComObject(oWorksheet) : oWorksheet = Nothing Taking the suggestions below using this code I can get Excel to completely quit with one caveat: GC.Collect() RaiseError("", "modGeneral." & "." & ().Name, Err.Number, Err.Description) Public Sub ReleaseObject(ByVal obj As Object) OWorkbook.SaveAs(Me.txtExportLocation.Text & "\sales.xlsx")
OExcel = CreateObject("Excel.Application") Then when I close Excel, the process goes back to being a background process.Ĭode: Dim oExcel As Excel.Application = Nothingĭim oWorkbook As Excel.Workbook = Nothingĭim oWorksheet As Excel.Worksheet = Nothing Once complete I make Excel visible and the process moves to Apps. I create and populate the workbooks in VB.NET with Excel hidden, the process (Microsoft Excel) shows in background processes in Task Manager Issue I'm running into is that I cannot get Excel to completely quit. I've created an application that creates a couple of Excel spreadsheets in VB.NET