4 Replies Latest reply on Dec 18, 2009 1:39 PM by hanyong

    ProcBook Addin Calling Macro/Public sub in Active Display


      Hi, Is it possible for a procbook addin in c# to execute a public sub defined in a display's VBA? Thanks.

        • Re: ProcBook Addin Calling Macro/Public sub in Active Display

          As far as I know, I don't think it is possible to do that with Processbook VBA. There are similar questions in the net about compiling and running Excel VBA outside Excel and it can be done with something like:

          'VBS CODE
          Dim appXL
          Dim objWb
          Dim path
          path = CreateObject(”WScript.Shell”).CurrentDirectory
          Set appXL = CreateObject(”Excel.Application”)
          Set objWb = appXL.Workbooks.Open(path & “\db\excel.xls”)
          appXL.Application.Run objWb.Name & “!” & “showform”

          But similar method would not work for Processbook it is implemented differently.


          This is a nice enhancement request that I suggest you file in at Tech Support. That way it will be archived in the system and will be considered by the development teams and product managers.

          • Re: ProcBook Addin Calling Macro/Public sub in Active Display

            Hi Jason,


            Directly within VBA, no, but with some trickery yes.


            In a nutshell what you need to do is use Visual Basic Extensibility so you can add and remove VBA methods to/from the VBProject for "ThisDisplay" then use ProcessBook symbol manipulation to finish off the process.  You add a symbol dynamically to the display, enable scripting, set Visible property to false, use VBE to add a method signature for one of the symbol's events (e.g. the Click event) and trigger the event.  Within the symbols event you add code that simply calls the public sub that you want to call from your addin. 

            Public Sub MySymbol_Click(ByVal lvarX As Long, ByVal lvarY As Long)

               Call ThePublicSubYouWantToCall

            End Sub

            Once the symbols event has finished you simply remove the method using VBE and remove the symbol (additionally you could set ThisDisplay.Modified = False so it appears to happen silently).


            Not straight forward but there is always a solution


            Give me a shout if you want a .Net method to do it, I have it somewhere in my archives.