4 Replies Latest reply on Jan 19, 2010 3:06 PM by andreas

    Debug Statements written to file from PBook VBA

    cdavis

      I'm trying to debug some PBook VBA code. When I single step from the PB VBA IDE everything seems to run as expected, but when I just open the .PDI and "let'er rip", PBook seems to hang. I figured logging debug statements into a file somewhere, from the VBA code might give me some insight into what's going on. The documentation leads me to believe that I can put messages into the local pipc.log file with LogMessage but I can't seem to get it to work. I'm open to suggestions and would appreciate any guidance or code snippets.

        • Re: Debug Statements written to file from PBook VBA
          andreas

          Hi Craig,

           

          writing to the PIPC log requires the PI API. Writing to the PI message log th PI SDK. I would suggest you add some Debug.Print lines to your code. Messages you write via Debug.Print end up in the Immediate window in the VBA editor. So you are not stepping through the code. Even if you have the VBA editor closed, you can later open it (after you run your code) and see in the Immediate window the result. Just try the following (with a MS Form Command Button:

          Private Sub CommandButton1_Click()
              Dim dt As Date
              dt = DateTime.Now
              Debug.Print (dt & " - Test")
          End Sub

          Hope this helps

            • Re: Debug Statements written to file from PBook VBA
              cdavis

              Andreas

               

              Ah, great to know! Didn't realize Debug.Print would show up when VBA IDE wasn't open. This is very useful.

               

              Also determined that writing to a file for debug isn't very difficult:

              Open "Debug.txt" For Append As #1
              Print #1, (Time$) + " Some useful debug text (Entering Sub Blah Blah)"
              Close #1

              When you say I can write to the PI message log via the SDK, did you mean the message log on the PI Server?