launcing/restoring an application from a form (1 Viewer)

J

jondodd

Guest
Hi, I orginally posted something in the macros section but realise this is a VB thing. It is really trivial but someone please help.

I want to have a button on a form that when pressed opens an application, or if it is already open restores it. Importantly the focus should return to the access application.

I have used shell command and AppActivate in separate modules - but my VB limits have been easily reached.

Also can I specify the location of the launced/restored window?

many thanks for your help

Jon
 

doulostheou

Registered User.
Local time
Today, 03:54
Joined
Feb 8, 2002
Messages
314
Not sure if this helps, but you can use the FollowHyperlink command to open applications.

Simply place the following in the onclick event of your button:

FollowHyperlink "C:/location/filename.exe"

I use this to open a pdf that we are constantly using and it does bring it to the focus if it is open in the background. I'm not sure what it would do though if you are trying to open an app that allows multiple sessions. It might open a new session.
_______

Sorry. I just realized I misread your initial post. This might not help either, but you can open an application with no focus. I'm guessing this isn't what you want either though, because even though it removes the focus from the app, it doesn't bring the database back into focus.

Dim ShellFunction
ShellFunction = Shell("msaccess.exe" & " " & "DatabasePath.mdb", vbNormalNoFocus)

[This message has been edited by doulostheou (edited 05-13-2002).]
 

miscnine

New member
Local time
Today, 03:54
Joined
Jun 14, 2002
Messages
9
Thank you!

I have been looking for a way to open explorer with a folder location specified by the user, and your way was the easiest thing I have ever done in Access. I spent hours upon hours looking througb several differnt websites, including this one over and over again, and could not find any explaination on how to open exlorer witha text box defining the location. And you did it in 4 lines. Here is my code for anyone who needs to open a folder in explorer using user defined text in a field.

'CODE BEGIN********
Private Sub CommandButton1_Click()

Dim ShellFunction
Dim Folder As String

Folder = Me.FolderLocation 'text field for user to type in the folder location, ie C:\windows
ShellFunction = Shell("explorer.exe" & " " & Folder, vbMaximizedFocus)

End Sub
'END CODE*********

Thank you.

miscnine
 

Users who are viewing this thread

Top Bottom