I'm read many of the threads on Excel not closing - and just can't get it to sort my coding...
Any help in sorting this would be greatly appreciated.
The code can only run once as Excel isn't closing properly and that is causing difficulty.
Code:
Public Function dataExcel(Item As String, Topic As String)
Dim oExcel As Excel.Application Dim objActiveWkb As Excel.Workbook
Dim objActiveSht As String
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
oExcel.Workbooks.Open "C:\GoldenWaves\mktData.xls"
objActiveSht = "Sheet1"
Set objActiveWkb = oExcel.ActiveWorkbook
oExcel.Worksheets(1).Activate
objActiveWkb.Worksheets(objActiveSht).Cells(2, 6).Value = Topic
objActiveWkb.Worksheets(objActiveSht).Cells(2, 7).Value = Item
RANGE("A1:E301").Select
Selection.ClearContents
objActiveWkb.Application.Run ("updateBars")
objActiveWkb.Worksheets(objActiveSht).Cells(2, 6).Value = ""
objActiveWkb.Worksheets(objActiveSht).Cells(2, 7).Value = ""
objActiveWkb.Worksheets(objActiveSht).Cells(1, 1).Value = "DATE"
objActiveWkb.Close savechanges:=True
oExcel.Quit
Set objActiveSheet = Nothing
Set objActiveWkb = Nothing
Set oExcel = Nothing
End Function
Any help in sorting this would be greatly appreciated.
The code can only run once as Excel isn't closing properly and that is causing difficulty.