Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ina ina is offline
external usenet poster
 
Posts: 120
Default Close an application with sendkeys

Hello,

This is my code to open my program from excel;

Public Sub OpenPLaunchShell()
On Error GoTo Err_PLaunch

Dim strappPack As String
Dim BoPack As Boolean


On Error Resume Next

strappPack = "C:\Program Files\PLaunch\PLaunch.exe"



If Err < 0 Then


BoPack = True ' if no error PLaunch is open
Err.Clear
MsgBox "PLaunch is not open"
Call Shell(strappPack, 2)
AppActivate strappPack
Exit Sub

Else
Exit Sub
MsgBox "Found PLaunch open"
End If

'Exit from the code
ExitCode:
Exit Sub

'Error Handler
Err_PLaunch:
MsgBox Err.Description
Resume ExitCode


End Sub


This is the sub to close my program; but the problem is that I close
the visual studio when I try to execute this code:


Sub ClosePLaunch()


Dim strappPack As String

strappPack = "C:\Program Files\PLaunch\PLaunch.exe"


'Close PLaunch
SendKeys "%{F4}", True
DoEvents

End Sub

Someone has any suggestion how to close an application on sending the
Alt+F4 key.

Ina

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default Close an application with sendkeys

If you know the Windows Handle of your application (Use the FindWindow API),
you can close it using the SendMessage or PostMessage API call.
  #3   Report Post  
Posted to microsoft.public.excel.programming
ina ina is offline
external usenet poster
 
Posts: 120
Default Close an application with sendkeys

Thank you I used the createobject and now it is fine. but the program
open twice and I do not know why

Ina

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
The application SendKeys Jim333[_6_] Excel Programming 2 August 17th 05 05:44 AM
SendKeys and Application.ScreenUpdating Michael Malinsky[_2_] Excel Programming 3 March 23rd 05 10:40 PM
Close Dialog Box with SendKeys Jim May Excel Programming 3 October 4th 04 04:25 PM
SendKeys to a remote server application green78[_5_] Excel Programming 0 July 28th 04 08:19 PM
Application.sendkeys Adrie Rahanra Excel Programming 1 October 15th 03 04:29 PM


All times are GMT +1. The time now is 01:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"