PC Review


Reply
Thread Tools Rate Thread

automation excel to access

 
 
goaljohnbill
Guest
Posts: n/a
 
      20th May 2009
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
 
Reply With Quote
 
 
 
 
ryguy7272
Guest
Posts: n/a
 
      21st May 2009
Look here:
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
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access automation leaves Excel open which in turn locks 2nd automation attempts EagleOne@discussions.microsoft.com Microsoft Access 8 30th Jun 2008 01:27 AM
Automation to Excel leaves Excel open until Access closed EagleOne@microsoftdiscussiongroups Microsoft Access 4 24th Jun 2008 11:00 PM
automation on excel(automated from Access VBA code) stops when opening another excel file thread Microsoft Access 1 27th Apr 2007 09:07 PM
Access-to-Excel Automation - Saving Excel w/ Custn Filename =?Utf-8?B?Qm9iIEJhcm5lcw==?= Microsoft Access VBA Modules 1 2nd Mar 2007 04:25 AM
Excel Automation - Access wants to re-open excel sheet when finish =?Utf-8?B?cGFzdG90bmlrcg==?= Microsoft Access VBA Modules 0 12th Apr 2006 07:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:44 PM.