Open Excel Focus

M

Martin

Hello,

I have this code which works:

Call Shell("C:\Program Files\Microsoft Office\Office11\Excel.exe
""MyFileName""", 3)

I understand that 3 indicated maximise focus but it does not. Excel opens
but I as the user have to navigate to it from say the task bar.

Does anyone have any other suggestions?

Many thanks in advance,

Martin
 
R

Rob Wills

That works fine on my pc....

the other way is to add the Excel library to the references then you can
open your application like this...
========================
Sub Open_Excel
Dim appExcel As excel.Application
Dim wbk As excel.Workbook

Set appExcel = excel.Application
appExcel.Visible = True
Set wbk = appExcel.Workbooks.Open(myfilename)


=================================
 
M

Martin

Hi Rob,

Thanks, this does work better although after it opens and maximises / set
Excel focus, I then return to my Access form.

I cant see why this would happen but thanks for the advice...
 
F

fredg

Hello,

I have this code which works:

Call Shell("C:\Program Files\Microsoft Office\Office11\Excel.exe
""MyFileName""", 3)

I understand that 3 indicated maximise focus but it does not. Excel opens
but I as the user have to navigate to it from say the task bar.

Does anyone have any other suggestions?

Many thanks in advance,

Martin
No need to use Shell.
Use this instead. Replace TheFolderName with the name of the folder in
which the Workbook is stored. Replace MyFileName with the name of the
workbook.

Application.FollowHyperlink ""C:\TheFolderName\"MyFileName.xls"
 
M

Martin

Thanks Fred. I have tried that already and the same applies. It opens then
reverts back to my Access form
 

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