run excel macro from access

G

Guest

I would like to print excel spreasheets from a specified xls file from Access.

I think I could create a macro in Excel. This would print the spreadsheets
requested. However, I don't know how to launch it from Access. What is the
VBA code for running this excel macro ?

Thanks in advance
Serge
 
D

Dave Patrick

This may give you some ideas.

Function Open_TrainLoadingEast()
Dim xlApp As Variant
Dim xlBook As Variant
Set xlApp = CreateObject("Excel.Application")
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


--
Regards,

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

:
|I would like to print excel spreasheets from a specified xls file from
Access.
|
| I think I could create a macro in Excel. This would print the spreadsheets
| requested. However, I don't know how to launch it from Access. What is the
| VBA code for running this excel macro ?
|
| Thanks in advance
| Serge
 

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