Subscribe Bookmark RSS Feed

Automating JMP through visual basic: copying excel data to JMP data tables.

Highlighted
Eduardo

Occasional Contributor

Joined:

Aug 5, 2017

Hello all,

The script below is supposed to do the following: it runs a VBA code which copies the excel workbook data to JMP tables (using the JMP library jmp.tlb). The first part is intended to load the reference JMP in excel so that functions associated with JMP automation can run. The second part exports all the workboook sheets to JMP data tables. When I run this code I get the following error: User-defined type not defined at the

Dim MyJMP As JMP.Application line. If I run the first part alone, the code works: it sets a check mark to the JMP reference (under tools>>references at the VBA editor). If I run the second part (after setting manually the check mark for JMP under tools>>references), it also works. Thus I do not understand what is wrong. Any help appreciated :-) many thanks!
Eduardo  

 

 

Sub export()
 
'Add JMP reference
'PART 1
 
On Error Resume Next
Application.VBE.ActiveVBProject.References.AddFromFile _
"C:\Program Files\SAS\JMP\12\jmp.tlb"
On Error GoTo 0
 
'This part exports all tabs in the excel workbook to JMP as tables
'PART 2
 
Dim MyJMP As JMP.Application
Dim JMPdoc As JMP.Document
Set MyJMP = CreateObject("JMP.Application")
MyJMP.Visible = True
Set JMPdoc = MyJMP.OpenDocument(ThisWorkbook.FullName)
Dim JMPdt As JMP.DataTable
Set JMPdt = JMPdoc.GetDataTable
 
End Sub