Opening Element Relative ProcessBook Display From Excel

Discussion created by espo89 on Dec 16, 2010
Latest reply on Dec 17, 2010 by hanyong

I'm trying to open a ProcessBook display which is element relative from within some VBA code in excel.   What appears to be happening is the display opens, however the "Element Relative Display" Task pane does not, esentially giving the display no context to act on.   My ultimate goal is to open the display, set the start and end times, set the element context, then save the display back out as a graphics file (to then be loaded into some reports).  


Also, whenever I try and set or even display the current context of the display,  I get the standard "Object or with variable not set" showing there is actually no contexthander created for the display.


The function I'm using (without the context setting part) is:

Private Sub cmbRun_Click()      Dim PBfile As String     Dim OutputFile As String     Dim Context As String     Dim StartTime As String     Dim EndTime As String     Dim ErrorStr As String     Dim PBApp As PBObjLib.Application     Dim PBDisplay As PBObjLib.Display          ' Get input values from Sheet     PBfile = Range("C4").Value     StartTime = Range("C5").Value     EndTime = Range("C6").Value     Context = Range("C7").Value     OutputFile = Range("C8").Value          'Load ProcessBook     On Error Resume Next     Set PBApp = GetObject(, "piprocessbook.application.2")     On Error GoTo RunError     If PBApp Is Nothing Then         Set PBApp = CreateObject("piprocessbook.application.2")     End If          'Open the display     Set PBDisplay = PBApp.Displays.Open(PBfile, 1)              Call PBDisplay.SetTimeRange(StartTime, EndTime)     Call PBDisplay.SaveAs(OutputFile, pbpdFormatJPEG)          Exit Sub      RunError:     ErrorStr = "Error Number: " & Err.Number & vbCrLf     ErrorStr = ErrorStr & "Error Description: " & Err.Description     MsgBox ErrorStr, vbCritical + vbOKOnly   End Sub

 What am I missing such that the display doesn't have any context when it's opened?   Note that the display opens fine when using "File->Open" in processbook and the element Relative addin in PB is loaded at startup.  Also, the above code is able to set the time range and output to a jpg fine.


I've also tried using:

'Open the display     Set PBDisplay = PBApp.ProcBooks.Open(PBfile)

 To open the display as detailed in the Process Book ActiveX Scripting course materials (I think it's in chapter 5) and get the same results.