How to open, refresh, save Excel workbook from Access?

K

KitenutDave

From an Access module, I need to open, refresh, and save a spreadsheet as
part of an overnight batch operation. A later process will query the
spreadsheet to get the updated results. Can anyone suggest some code to do
this (the opening, refreshing, and saving) that will work unattended?
Thx.
 
K

Klatuu

The code you referenced is good, but it does not open an existing xls file,
it creates a new one here:

objXL.Application.workbooks.Add
Set objActiveWkb = objXL.Application.ActiveWorkBook

To open an existing xls file:

Set objActiveWkb = objXL.Workbooks.Open(strGetFileName, 0, True)
Set objXlSheet = objActiveWkb.Worksheets("SomeSheetName")

SomeSheetName can be a text value that is the name of a worksheet or in can
be an index reference to the sheet.
 
S

Stefan Hoffmann

hi Klatuu,
The code you referenced is good, but it does not open an existing xls file,
it creates a new one here:
Yup, i know. Sometimes i'd like to make the people think themself :)


mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top