Running an Excel Macro from an Access Command Button

  • Thread starter Thread starter David Kennedy
  • Start date Start date
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
 
Back
Top