[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • Last Modified:

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?
0
Diz
Asked:
Diz
  • 6
  • 3
  • 2
  • +1
1 Solution
 
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
 
kamallCommented:
X = Shell ("c:\...\winword.exe c:\mydoc.doc", 1)   'or 3 instead of 1
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

  • 6
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now