ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Opening a spreadsheet using VB (https://www.excelbanter.com/excel-programming/274834-re-opening-spreadsheet-using-vbulletin.html)

Bob Phillips[_5_]

Opening a spreadsheet using VB
 
Zac,

This code does all you ask

Dim xlApp As Object

Set xlApp = CreateObject("Excel.Application")
With xlApp
.Workbooks.Open Filename:="c:\myTest\myFile.xls"
.Calculate
.DisplayAlerts = False
With .ActiveWorkbook
.Save
.Close
End With
.Quit
End With

I have not tested it with Access, but I did from Excel. The .Quit closes the
new Excel application down as well.

--

HTH

Bob Phillips

"zac" wrote in message
...
Hello,
I have a spreadsheet (XP) with links to query's in Access
XP and SQL 2000 that needs to be opened and refreshed
(Refresh All button is the one that works when done
manually) on all tabs. Would anyone be able to provide
some sample code in VB 6 that would show how to open and
refresh a spreadsheet, then save and close? The first 2
are more important though.

thanks,
Zac





All times are GMT +1. The time now is 11:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com