[mso] Access Unbound Object Frame Fails to Open Excel Chart

  • From: <Randy.Harding@xxxxxxxxx>
  • To: <mso@xxxxxxxxxxxxx>
  • Date: Thu, 17 May 2007 07:39:57 -0500

I believe this is an Excel issue even though I start out talking about  MS 
Access.
I have an Access application containing a form with two unbound object frames. 
Each object frame contains an Excel chart. The objects are set to "Auto 
Activate" on GetFocus. When I click on each object individually they open 
without any problems.

The problem is that I want to use a command button on the form whose OnClick 
process does a Me.cntlDeals.SetFocus and then a Me.cntlSchedule.SetFocus 
command. When I click on the command button Access activates a window 
containing Excel and the first object opens without any problems, but when 
Access attempts the second SetFocus command I get an Excel Application error. 
The error is:

The instruction at "0x300baff9" referenced memory at "0x00000000". The memory 
could not be "read".
When I click on the command button I sometimes get the error listed above. On 
other occasions when I click on the command button the first spreadsheet opens 
without problems and the second one opens, but only after I have made the 
Access window containing the command button active again.

I have tried putting a 4 second delay between the two SetFocus commands 
thinking that Excel needed more time to become fully functional before I 
attempted the second SetFocus. This did not work.

I don't understand how the .SetFocus command differs from actually clicking on 
the unbound object on the Access form. In both cases the focus is set on the 
unbound object frame thus the AutoActivate on GetFocus occurs. The only 
difference that I see is that when manually clicking on each form you actually 
have Access as the active window. When programmatically running the .SetFocus, 
Excel is the active window for the second .SetFocus command.

Clicking on the unbound object on my Access form sets the focus to that object. 
When I click on the first unbound object on the Access form Excel starts and 
the chart opens within that instance of Excel. When I click on the second 
unbound object the second chart opens within the instance of Excel which is 
already running. This works without failure. I think the key to this working 
without failure is that Access is the active window at the time the unbound 
object is activated.

If I place a MsgBox comment between the two .SetFocus commands the error goes 
away. Unfortunately, I have to go back to the Access form to reply to the 
MsgBox window. My users will not like having to do that. There must be 
something happening when I go back to Access to reply to the MsgBox that is 
clearing up the problem. I need to find some way to programmatically give the 
Access instance control (make the window active) without making its window 
visible. That is to say, keep the Excel instance visable while at the same time 
giving Access what it needs to get the second chart up and running.

Sorry for being so long-winded on this. Any suggestions?






Randy Harding

Shell Trading US Company
909 Fannin St. - Suite 700, Houston, TX  77010, USA

Tel: +1-713-230 3114
Email: Randy.Harding@xxxxxxxxx
Internet: http://www.shell.com


*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, visit the group's homepage and use the dropdown 
menu at the top.  This will allow you to unsubscribe your email address or 
change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to share files with the group, you must join our Yahoo sister group. 
 This group will not allow for posting of emails, but will allow you to join 
and share problem files, templates, etc.:  
http://tech.groups.yahoo.com/group/MicrosoftOffice . This group is for FILE 
SHARING ONLY.

If you are using Outlook and you see a lot of unnecessary code in your email 
messages, read these instructions that explain why and how to fix it:
http://personal-computer-tutor.com/abc3/v28/greg28.htm
*************************************************************

Other related posts: