Running an Excel Macro from an Access Command Button

D

David Kennedy

Hi ,

Can anyone help me with this, I am trying to run an excel macro from an
access command button.
I want the macro to Bold the Headings on a excel spreadsheet.
The code runs without any errors but the macro doesnt seem to work, I think
I have got the line
ExcelApp.ExecuteExcel4Macro "RUN(""PERSONAL.XLS!BoldHead"")" wrong

The code:

Private Sub cmdRunMac_Click()

Dim ExcelApp As Excel.Application
Dim ExcelBook As Excel.Workbook

Set ExcelApp = Excel.Application
ExcelApp.Visible = True
Set ExcelBook = ExcelApp.Workbooks.Open("C:\Documents and
Settings\emilie.vieville\Desktop\head.xls")

ExcelApp.ExecuteExcel4Macro "RUN(""PERSONAL.XLS!BoldHead"")"

ExcelBook.Save

ExcelApp.Quit
Set ExcelBook = Nothing
Set ExcelApp = Nothing


End Sub

Any help would be greatly appreciated

Thanks,
David K
 
G

Guest

Silly question, but if you have code that works, WHY do you need to execute a
macro?
 

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