Change focus from Access to Excel

A

Andy

Hi

I have an Access database for which I have written code
that outputs data to Excel and then runs an Excel macro.

The Excel object remains hidden while the macro runs. If
necessary, the macro will pop up a MsgBox but it doesn't
show on screen until you click on the Excel icon that
appears on the taskbar. As this is part of a loop, any
subsequent Excel message boxes do appear on screen. This
suggests to me that it has something to do with which
application has control/focus at the time the message box
is 'displayed'. My problem therefore is that I don't know
how to pass control to Excel so that the message box
appears first time.

A similar problem I have is that the Excel macro will
occasionally use the GetSaveAsFileName function to display
the SaveAs dialog box. However, unlike the problem above,
there is no way to actually view the SaveAs dialog box
while the Excel object is hidden and so the macro can't
continue. I have got round this by making Excel visible
before the GetSaveAsFileName function is used and then
hiding it again afterwards but I wonder if there is a more
elegant way of doing it.

Thanks in advance for any help!
 
S

Stan Scott

I believe that all you need to do is use the visible command, such as
"myExcelObj.visible".

Stan
 
A

Andy

Thanks Stan

However, I would prefer it if Excel remained hidden but
for the Excel MsgBox to appear 'on top' when it is
tirggered. Is this possible or will Excel have to be
visible?

Thanks

Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top