ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   automation excel to access (https://www.excelbanter.com/excel-programming/428751-automation-excel-access.html)

goaljohnbill

automation excel to access
 
I am exploring automation for excel and access using the following
code just to see how it works.

In access;

Dim appExcel As Excel.Application, appMacroWB As Excel.Workbook
Set appExcel = GetObject(, "Excel.Application")
appExcel.Visible = True

Set appMacroWB = appExcel.Workbooks.Open _
("T:\Groups\PAM\Meat Juice Lab\tdevelopment\Excel dev\Code
dictionary.xls")
appExcel.Run "'Code dictionary.xls'!test2cd"
Set apExcel = Nothing

In excel;

sub test2cd
MsgBox ("you have ran this macro from access")
Dim apAccess As Access.Application
Set apAccess = GetObject(, "Access.Application")
apAccess.Visible = True

apAccess.DoCmd.RunMacro "a_FromExcelMsgBox", , ""
Set apAccess = Nothing

end sub

The a_FromExcelMsgBox macro is just a msgbox to show me that it went
"back" to access

My problem is with the apAccess.Visible = True line I get the
following error:

run time error 2455
you have entered an expression that has an invalid reference to the
property visible

If I take that line out it leaves me in excel with a msgbox up in
access

I was wondering why it works for excel and not for access (btw i have
access 9 and xl 10)


thanks in advance

ryguy7272

automation excel to access
 
Look he
http://www.accessmvp.com/KDSnell/EXCEL_MainPage.htm

HTH,
Ryan---
--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"goaljohnbill" wrote:

I am exploring automation for excel and access using the following
code just to see how it works.

In access;

Dim appExcel As Excel.Application, appMacroWB As Excel.Workbook
Set appExcel = GetObject(, "Excel.Application")
appExcel.Visible = True

Set appMacroWB = appExcel.Workbooks.Open _
("T:\Groups\PAM\Meat Juice Lab\tdevelopment\Excel dev\Code
dictionary.xls")
appExcel.Run "'Code dictionary.xls'!test2cd"
Set apExcel = Nothing

In excel;

sub test2cd
MsgBox ("you have ran this macro from access")
Dim apAccess As Access.Application
Set apAccess = GetObject(, "Access.Application")
apAccess.Visible = True

apAccess.DoCmd.RunMacro "a_FromExcelMsgBox", , ""
Set apAccess = Nothing

end sub

The a_FromExcelMsgBox macro is just a msgbox to show me that it went
"back" to access

My problem is with the apAccess.Visible = True line I get the
following error:

run time error 2455
you have entered an expression that has an invalid reference to the
property visible

If I take that line out it leaves me in excel with a msgbox up in
access

I was wondering why it works for excel and not for access (btw i have
access 9 and xl 10)


thanks in advance



All times are GMT +1. The time now is 05:38 PM.

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