OK I must be dumb!!!

J

Jason Dawson

Ok guys... I have tried and tried to get what i believed to be a very simple
thing to happen... but no...

All i am trying to achieve is a little bit of code that would open an
existing Excel spreedsheet file so that i can transfer data to it from my
database

I can
1) open a brand new excel spread sheet
2) transfer the data
3) even modify the format of the spreadsheet

But i can't seem to get it to open the existing file, can any one offer
options?

Thanks

Jason
 
G

Glenn

Try this code substituting Path with the full path of your
excel book to open....

Dim xlApp As Excel.Application
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlApp.Workbooks.Open Path


Glenn
 
A

Arvin Meyer

This ought to work for you (it does for me):

Dim appXL As Excel.Application
Dim wkb As Excel.Workbook
Dim wks As Excel.Worksheet

Set appXL = New Excel.Application
Set wkb = appXL.Workbooks.Open("C:\MyFolder\MyExcelWorkbook.xls")
Set wks = wkb.Worksheets(1) ' Open Sheet 1
appXL.Visible = True
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 

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