Changing Focus To Open App

I am writing a program which opens a particular Word file. The document opens correctly but my VB app still has focus. I would like to have the focus switch to the Word doc when it opens. Any suggestions?
DizAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SiM99Commented:
using Shell ?
0
manojaminCommented:
If you are using Automation use Activate method... (this is a sample)

Private wrdApp As Object
Private Sub cmdStart_Click()
    Set wrdApp = CreateObject("Word.Application")
        wrdApp.Visible = True
        wrdApp.Activate
End Sub
Private Sub cmdEnd_Click()
    wrdApp.quit
    Set wrdApp = Nothing
End Sub

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kamallCommented:
X = Shell ("c:\...\winword.exe c:\mydoc.doc", 1)   'or 3 instead of 1
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

kamallCommented:
If you like my *one-line* solution, the points are mine :-)
0
SiM99Commented:
ok, c:\**what**\winword.exe ?
c:\windows ?
what if they installed unser c:\Win98 or c:\Win95 ??

then what's your *one-line* solution gonna do ?


It's bes to use the API to run the file... ShellExecute
0
kamallCommented:
Sim99,
Diz didn't specify his exact intension, i.e. if he is distributing his program or installing it on a machine somewere.
Thats why I suggested this solution.
Of course, if he is going to distribute it, then the best solution is to use ShellExecute.
0
SiM99Commented:
Yeah, i know :)
You're best off using ShellExecute anyway, there's also an API call to set the program into focus, and it's a lot more versatile
0
manojaminCommented:
OK!!!!

Sorry kamall and SiM99...

I think s/he likes the automation rather than APIs...

0
SiM99Commented:
Yeah, only cause you were the first to give an answer, no matter how good/bad it was, it was accepted. That doesnt mean that it was the best.
0
SiM99Commented:
and WTF is a s/he ?
0
SiM99Commented:
and WTF is a s/he ?
a transvestite ?
0
lan_nurCommented:
SiM99, could you please give me the API function for focusing an app by its TITLE?
Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.