Create or open an excel file as an object or workspace

F

Frank

I have done this in the past, but unable to find my old
code to do it. I am trying to export or import data to
excel in code, and which also allows me to use the excel
code to format the spreadsheet from Access.
 
K

Ken Snell

Here's some sample code for opening an EXCEL workbook:

Public Sub TestMacroRun()
Dim xlx As Object, xlw As Object
Set xlx = CreateObject("excel.application")
Set xlw = xlx.workbooks.Open("C:\Filename.xls")
' .... code here for what you want to do....
xlw.Save
xlw.Close False
xlx.Quit
Set xlw = Nothing
Set xlx = Nothing
End Sub
 
F

Frank

Ken, Thanks alot for the help. That is what I was looking
for, but like I said, I had lost that old code.
 

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