ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Calling Excel macro from Access errors (https://www.excelbanter.com/excel-programming/376563-calling-excel-macro-access-errors.html)

Snowsride

Calling Excel macro from Access errors
 
Hi

I'm calling an Excel macro from Access and get an error

440 Method 'Run' of object '_Application' failed

I've cut and pasted the offending piece of code into a separate procedu

Sub Test()

ActiveWorkbook.SaveAs Filename:= _
"C:\Apps\Reward and Recognition\Quarterly reports\" _
& "Quarterly KPIs.xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False

ActiveWorkbook.Close SaveChanges:=False

End Sub

Help appreciated.


NickHK

Calling Excel macro from Access errors
 
How are you calling this from Access ?

NickHK

"Snowsride" wrote in message
...
Hi

I'm calling an Excel macro from Access and get an error

440 Method 'Run' of object '_Application' failed

I've cut and pasted the offending piece of code into a separate procedu

Sub Test()

ActiveWorkbook.SaveAs Filename:= _
"C:\Apps\Reward and Recognition\Quarterly reports\" _
& "Quarterly KPIs.xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False

ActiveWorkbook.Close SaveChanges:=False

End Sub

Help appreciated.




Snowsride

Calling Excel macro from Access errors
 
Dim objExcel As Excel.Application

Set objExcel = Excel.Application
With objExcel
..Visible = True
Workbooks.Open("C:\Apps\Reward and Recognition\" _
& "Quarterly reports\Template.xls").Activate

..Run "Test"

End With
---------------------------

Access opens Template.xls OK and runs other code in the Test macro but it
fails when it tries to save Template.xls under another name.




"NickHK" wrote:

How are you calling this from Access ?

NickHK

"Snowsride" wrote in message
...
Hi

I'm calling an Excel macro from Access and get an error

440 Method 'Run' of object '_Application' failed

I've cut and pasted the offending piece of code into a separate procedu

Sub Test()

ActiveWorkbook.SaveAs Filename:= _
"C:\Apps\Reward and Recognition\Quarterly reports\" _
& "Quarterly KPIs.xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False

ActiveWorkbook.Close SaveChanges:=False

End Sub

Help appreciated.






All times are GMT +1. The time now is 01:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com