Hello,
I have some simple code that runs on a button click in Access. It Opens Excel and inputs a couple of values of textboxes.
The issue I am having is that somehow Excel is not closing properly once the button is clicked, causing it to error thereforeafter until I go into Task manger and kill the Excel Task. Am I missing something clear? Thank
I have some simple code that runs on a button click in Access. It Opens Excel and inputs a couple of values of textboxes.
The issue I am having is that somehow Excel is not closing properly once the button is clicked, causing it to error thereforeafter until I go into Task manger and kill the Excel Task. Am I missing something clear? Thank
VBA Code:
Private Sub Export_Click()
Dim xls As Excel.Application
Dim wkb As Excel.Workbook
Dim wks As Excel.Worksheet
Set xls = CreateObject("Excel.Application")
Set wkb = xls.Workbooks.Open("c:\users\x\desktop\logger\log.csv")
Set wks = wkb.Worksheets("log")
With xls
.Visible = False
ActiveWorkbook.Sheets("log").Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(, 3) = Array(Me.txtProduct.Value, Me.txtQuantity.Value, Me.txtCountUp.Value)
Set wks = Nothing
Set wkb = Nothing
Set xls = Nothing
.ActiveWorkbook.Close True
End With