run Excel macro from Access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an Access database when the user pushes a button and it opens 2 Excel
files. Once both files are open, I would like to run macro in one of the
Excel files that was just opened.

How can I start the macro based in Excel? Thanks for the help.
 
This may give you some ideas.


Function Open_TrainLoadingEast()
Dim xlApp As Variant
Dim xlBook As Variant
Set xlApp = CreateObject("Excel.Applicatio­n")
Set xlBook = xlApp.Workbooks.Open("C:\data\­excel\TrainLoading.xlt")
xlApp.sheets("Data").range("e1­") = Forms!frmLoading.txtDate
xlApp.sheets("Data").range("e2­") = Forms!frmLoading.opt1.Value
xlApp.Run "EastPrint"
'xlApp.Application.Visible = True
xlBook.Close (False)
xlApp.Quit
Set xlApp = Nothing
Set xlBook = Nothing
End Function


Else just call them from the Workbook_Open() event.

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
|I have an Access database when the user pushes a button and it opens 2
Excel
| files. Once both files are open, I would like to run macro in one of the
| Excel files that was just opened.
|
| How can I start the macro based in Excel? Thanks for the help.
| --
| JT
 
Back
Top