How to close session without messagebox??
How to close session without messagebox??
(OP)
I am opening a session and downloading files, and I simply want to close the session and the instance of Extra without anyone having to click "Yes" on a messagebox. The only way I could find to close the session is as follows:
---------------
QuitAllSessions.ebm
---------------
Sub Main
Pause(2) 'make sure previous macro has finished
dim system as object
set system = CreateObject("Extra.System")
if (system is nothing) then
msg = "CreateObject(""Extra.System"") failed." + chr(13)
msg = msg + "Try uninstalling, then reinstalling EXTRA! Personal Client."
msgbox msg
exit sub
end if
system.quit
End Sub
----------------
----------------
I use this code to call QuitAllSessions.ebm:
----------------
----------------
ret = session.WaitForDisconnect(99999999999)
rc = shell("ebrun quitallsessions.ebm")
----------------
----------------
The code works fine but it pops up an "Are you sure.." Yes/No messagebox. Can this be done without the messagebox being displayed??
Thanks!!
---------------
QuitAllSessions.ebm
---------------
Sub Main
Pause(2) 'make sure previous macro has finished
dim system as object
set system = CreateObject("Extra.System")
if (system is nothing) then
msg = "CreateObject(""Extra.System"") failed." + chr(13)
msg = msg + "Try uninstalling, then reinstalling EXTRA! Personal Client."
msgbox msg
exit sub
end if
system.quit
End Sub
----------------
----------------
I use this code to call QuitAllSessions.ebm:
----------------
----------------
ret = session.WaitForDisconnect(99999999999)
rc = shell("ebrun quitallsessions.ebm")
----------------
----------------
The code works fine but it pops up an "Are you sure.." Yes/No messagebox. Can this be done without the messagebox being displayed??
Thanks!!
RE: How to close session without messagebox??
Hi,
Here's how I close my session from Excel VBA...
CODE
Public oSess As ExtraSession
Public oScrn As ExtraScreen
Sub CloseIMS_Session()
oSess.Close
Shell "tskill EXTRA"
Set oScrn = Nothing
Set oSess = Nothing
Set oSystem = Nothing
End Sub
Skip,
Just traded in my old subtlety...
for a NUANCE!
RE: How to close session without messagebox??
RE: How to close session without messagebox??
CODE
Dim Sys As Object
Set Sys = CreateObject("EXTRA.System")
' Assumes one or more open sessions
Sys.Sessions.CloseAll
End Sub
CODE
Sub Main()
Dim Sys As Object, Sess As Object
Set Sys = CreateObject("EXTRA.System")
' Assumes an open session
Set Sess = Sys.ActiveSession
MsgBox "Press to close session."
Sess.Close
End Sub
RE: How to close session without messagebox??
RE: How to close session without messagebox??
RE: How to close session without messagebox??
Sub Main()
Sendkeys "%F{up}+{Enter 2}"
End Sub
RE: How to close session without messagebox??
Skip, the TSKILL probably works fine for your purposes but others need to be aware of what the TSKILL is really doing behind the scenes. The tskill on Extra will kill all extra processes, whether they are 'in scope' of your application or not.
In my environment, users may be using an extra session which is not being used for automation so the tskill would close their session on them, even though that session really has nothing to do with the macro thats closing it. When our macros close sessions, the dialog box is not displayed and I found the best method is to disable the option via the settings as boatbum cleverly suggested.
On another side note, it would probably be in a coders best interest to reference the session being used by the macro specifically rather than with the activeSession. Doing this will allow your macro to interact with more than one session if necessary. if you have any questions about how to do this, let me know and i would be more than happy to provide code
RE: How to close session without messagebox??
Yes, in my environment, one can only have ONE session open. So that's a good point!
Skip,
Just traded in my old subtlety...
for a NUANCE!