Export to Excel and run macro....

M

Mr. Smith

Hi.
Might not be correct forum but I'll try.

I have an option in my .mdb application to let users choose between standard
Access report output or export to Excel. The Excel version contains the
correct data, but look like h*ll. How can I run a macro (stored somewhere on
the network) which will format the content to fit with our visual identity?

Just need to know where I should place the code, or if (perhaps) I should
make an .xlt file as export destination.

Regards
Mr. Smith
 
D

David Lloyd

You have at least two options here. One option is to embed the macro in the
Excel workbook you are exporting the report to. After the report is
exported, you can access the Excel workbook through automation and run the
Excel macro by using the Run method. For example:

Dim xlapp as New Excel.Application
Dim wkb as Workbook

Set wkb = xlapp.Workbooks.Open("C:\MyReportWorkbook.xls")

wkb.Application.Run("MyExcelMacroName", [Parameter1], [Parameter2], ...)

The second alternative is to just use the Excel object model through
automation to format your workbook/worksheet. You can gain a reference to
the workbook as above, and then use automation to perform the appropriate
formatting.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


Hi.
Might not be correct forum but I'll try.

I have an option in my .mdb application to let users choose between standard
Access report output or export to Excel. The Excel version contains the
correct data, but look like h*ll. How can I run a macro (stored somewhere on
the network) which will format the content to fit with our visual identity?

Just need to know where I should place the code, or if (perhaps) I should
make an .xlt file as export destination.

Regards
Mr. Smith
 
Top