cancel
Showing results for 
Search instead for 
Did you mean: 

VB.net Scripting, Can not Disconnect a running script

Former Member
0 Kudos

I am creating forms (in Microsoft Visual Studio 2010) to interact between SAP and Excel and everything runs fine but I can't disconnect the script when its finished.

SapGuiAuto = GetObject("SAPGUI")

ApplicationSAP = SapGuiAuto.GetScriptingEngine

For Connect = 1 To ApplicationSAP.Children.Count

chkme = ApplicationSAP.Children.Count

Connection = ApplicationSAP.Children(Connect - 1)

Session = Connection.Sessions(0)

clientDISP = Sessionsap.INFO.clienT

sessiondisp = Sessionsap.INFO.systemName

Next

SapGuiAuto = Nothing

ApplicationSAP = Nothing

Connection = Nothing

The following line disconnects when written in Excel VB but does not work with Microsoft forms:

Session = Nothing

The script running icon (barber pole) is always spinning after running this, how do I disconnect (end script connection)?

Thanks,

Brian

Edited by: BFeaster on Dec 30, 2011 8:57 PM

Accepted Solutions (0)

Answers (1)

Answers (1)

script_man
Active Contributor
0 Kudos

Hi Brian,

I would always use for the objects the command "set".

For example:


set session = nothing

Much more important is than the script running icon (barber pole), the fact that wscript.exe is not visible in Task Manager when a script is closed. In theory you should not set objects on nothing. These will be destroyed automatically when you exit the script.

The end of a script can also be initiated by this command:


wscript.quit

Regards,

ScriptMan

Former Member
0 Kudos

Thanks ScriptMan

the "Set" command works with vb in excel but when using Visual Studio (2010), the program automatically removes it as its not needed.

As far as the "wscript.quit", the "wscript" is not recognized so I assume it has to be initialized.

I'm not sure how I would initialize it to be seen as the running script.

Thanks again for the help, let me know if you have any other ideas.

Edited by: BFeaster on Jan 3, 2012 3:18 PM