Automatic excel open

G

Guest

I have done a project in access and created Report with the help of Macros to
export into Excel sheet. After creating Excel sheet I have created one more
Macro to create good look in Excel. Should I do it from Access itself to
operate excel macro.?

I mean my excel macro should work when I export from access itself. Pl.
provide example also...When I export with the help of access macros, it
saves excel file in C:\ as c:\ss.xls and then I am accessing ss macro in
Excel.

Thanks, Siva from India...
 
R

Ron2006

here is code that runs an excel macro from within access:

Set xlApp1 = CreateObject("Excel.application")
xlApp1.Application.Visible = True
Set xlWb2 = xlApp1.Workbooks.Open("path\BOM2.xls") ' macro was
here
Set xlWb1 = xlApp1.Workbooks.Open("path\" & filename & ".xls")
'sheet to run in
Set xlWs = xlWb2.Worksheets("Sheet1")
xlApp1.UserControl = True
xlWs.Activate
xlApp1.Run "BOM2!macroname"
xlApp1.Save
xlApp1.Quit
 

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