Open Excel Spreadsheet Refresh and Save not working.. (1 Viewer)

Number11

Member
Local time
Today, 04:39
Joined
Jan 29, 2020
Messages
607
IO am using this code to open and refresh an external excel spreadsheet from access, its not working?


Dim appExcel As Object
Dim excelwb As Excel.Workbook
Set appExcel = CreateObject("Excel.Application")
Set excelwb = appExcel.workbooks.Open ("c:\Log\dataset2.xlsx")
excelwb.refreshall
Set excelwb = Nothing
Set appExcel = Nothing
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:39
Joined
May 7, 2009
Messages
19,230
you also need to Save it after Refreshing, and Close all object properly:

excelwb.Application.Calculate
excelwb.Close True
set excelwb = Nothing

appExcel.Quit
set appExcel = Nothing
 

Isaac

Lifelong Learner
Local time
Yesterday, 20:39
Joined
Mar 14, 2017
Messages
8,777
What is your intention or desire by the refreshall command? It could be that what you want to do, that doesn't cover. What about it, isn't working?

And as arnel said, you probably want to close the workbook or quit excel too.
 

Users who are viewing this thread

Top Bottom