cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
keith_a_kraft
Level II

vbs createobject vs getobject

I am trying to write a VBS/VBA script in powerpoint which will get some information from a running JMP session. 

Here is the basic code.

Sub test()

    Dim myjmp As JMP.Application

    Set myjmp = CreateObject("JMP.Application")

    myjmp.Visible = True

     'some code to test running jsl

    myjmp.RunCommand ("transfer_data = 35;")

    areaHeight = myjmp.GetJSLValue("transfer_data")   

End Sub

If the user has a jmp session open that was started by using the start menu or desktop icon, the JMP session will stay open after the script runs.  If the user started JMP by double clicking on a .jmp file the JMP session will close after the script finishes even though there is no myjmp.quit call in there.

How do I make the JMP session stay open in both cases? 

Other Notes:

Other applications tend to have something like app.usercontrol = true or you can use set myapp = GetObject(,"application") to get an object of the open session.  (GetObject(,"JMP.Application") does not work for JMP11)

This doesn't seem to do anything

myjmp.EnableInteractiveMode True

If I create an empty data table, then after the script finishes the jmp session will stay open.

Set dt = myjmp.NewDataTable("")

JMP11.2.1 and Windows 7.

1 ACCEPTED SOLUTION

Accepted Solutions
keith_a_kraft
Level II

Re: vbs createobject vs getobject

I ended up removing all jmp objects from VBS and passed the data by creating a temp .vbs file using JSL that set a bunch of variables in vbs and read them in.

Sub IncludeExecuteOptions()

  Dim fso, f

  Set fso = CreateObject("Scripting.FileSystemObject")

  Dim tempfolder

  Const TemporaryFolder = 2

  Set tempfolder = fso.GetSpecialFolder(TemporaryFolder)

  Set f = fso.OpenTextFile(tempfolder & "\ExecuteOptions.vbs", 1)

  str = f.ReadAll

  f.Close

  call ExecuteGlobal(str)

end Sub

This method left the JMP session open no matter how it was started.

View solution in original post

4 REPLIES 4

Re: vbs createobject vs getobject

Hi Keith,

I think your JMP session is going away because you have the JMP.Application variable defined within the scope of the function.  When it goes out of scope, the object reference is deleted, which tells JMP to shut down.  If you find somewhere else to define the variable, it will probably stay open.  For Excel, having it defined in the Workbook Load function would work.  I don't have enough experience with PowerPoint to tell you where to put it there.  If you do this approach, you will have to be careful to call JMP.Quit when you really want it to go away.

Brian Corcoran

JMP Development

keith_a_kraft
Level II

Re: vbs createobject vs getobject

Hi,

I don't think it is just due to the scope of the function. 

You can write a 3 line test.vbs script like this:

Dim myjmp

Set myjmp = CreateObject("JMP.Application")

myjmp.Visible = True

which you run on the command line with cscript test.vbs and you get the same behaviour.  Session closed if started from double click on a file, session stays open if started from start menu.

Re: vbs createobject vs getobject

That would fail, because as soon as the Visible is run and the script completes your myjmp variable goes out of scope.  You would have to have a way of keeping the VBS script resident and running.

Brian

keith_a_kraft
Level II

Re: vbs createobject vs getobject

I ended up removing all jmp objects from VBS and passed the data by creating a temp .vbs file using JSL that set a bunch of variables in vbs and read them in.

Sub IncludeExecuteOptions()

  Dim fso, f

  Set fso = CreateObject("Scripting.FileSystemObject")

  Dim tempfolder

  Const TemporaryFolder = 2

  Set tempfolder = fso.GetSpecialFolder(TemporaryFolder)

  Set f = fso.OpenTextFile(tempfolder & "\ExecuteOptions.vbs", 1)

  str = f.ReadAll

  f.Close

  call ExecuteGlobal(str)

end Sub

This method left the JMP session open no matter how it was started.