Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing IE and Outlook with a button

Status
Not open for further replies.

FrankMars

Technical User
Dec 20, 2010
67
US
Hi,
I am opening IE and Outlook from a button on a form with the following code:

Private Sub OpenIEandOutlook_Click()

Dim x As Variant
Dim y As Variant
Dim Path1 As String
Dim Path2 As String

Path1 = "C:\Program Files\Internet Explorer\iexplore.exe"
Path2 = "C:\Program Files (x86)\Microsoft Office\OFFICE11\OUTLOOK.EXE"

x = Shell(Path1, vbNormalFocus)
y = Shell(Path2, vbNormalFocus)

End Sub

I would like to close the two programs from a single button. I have been unsuccessful using .quit. Any help would be appreciated. Thank you in advance.
 
When you open a program using Shell, Access simply hands control over to that program and the user has control over the events in that program, such as ending it. Doing the same thing using Access would require you to end the process on the machine, something that is usually not recommended, but if you want to give it a shot Google "End running process VBA" and you will get all kinds of code examples. Your button to start the app should store the process ID, then your button to end the app needs to kill the proces with that ID. In the end, you'll end up with a bunch of corrupted crap and you'll have to re-install Office a few times, because ending programs by throwing hand grenades at them never is a good solution.
 
There is a control available where you can imbed the IE browser into an Access form, I don't know if there is anything like that available for Outlook but you can code an actual email front end into an Access form pretty easy. Google away.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top