Create or open an excel file as an object or workspace

  • Thread starter Thread starter Frank
  • Start date Start date
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.
 
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
 
Ken, Thanks alot for the help. That is what I was looking
for, but like I said, I had lost that old code.
 
Back
Top