Opening and excel spreadsheet from access

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

How can I open a specfic Excel workboork/worksheet from
inside of access?

I'd like to add a button cotrol to a form to open a
specific Excel spreadsheet which is on another computer
on a network.

Thanks in advance.
..
 
Here's some sample code for opening an EXCEL workbook:

Public Sub TestMacroRun()
Dim xlx As Object, xlw As Object, xls As Object, xlc As Object
Set xlx = CreateObject("Excel.Application")
xlx.Visible = True
Set xlw = xlx.workbooks.Open("C:\Filename.xls")
Set xls = xlw.Worksheets("WorksheetName")
Set xlc = xls.Range("A1")
' put code here to write into the cells etc.
' .
' .
' .
Set xlc = Nothing
Set xls = Nothing
xlw.Save
xlw.Close False
Set xlw = Nothing
xlx.Quit
Set xlx = Nothing
End Sub
 
Back
Top