3 Replies Latest reply on Jun 18, 2010 1:51 AM by hanyong

    Search for batches in Excel VBA by unit

    mmulder6

      Hello,

       

      I am writing some VBA code in Excel to retrieve batchID's and put this into a listview.
      I worked out the code for getting the batchinformation but I could not find anyway to include the unit name as a search parameter

       

      When you do this in Excel using formulas there is an option called PIBVUnitBatchSearchMasks which is a subset of PIBVSearch. I want to have the same search option via VBA. I'm currently using a Set batchList = BatchDB.PIBatchSearch(SearchStart, SearchEnd) and I get a nice result of all batches within the specified time period but this result is over multiple units that have nothing to do with each other.

       

      Does anyone have any experience with this?

       

      Any help is appreciated!

       

      Kind regards,

       

      Martin

        • Re: Search for batches in Excel VBA by unit
          hanyong

          Perhaps you can try to use PIModule.PIUnitBatchSearch() function to find the PIUnitBatches of the Unit? Given that you know the unit, we can get the PIModule (PIUnit) that represent the Unit, then call the function. If you look at the PI SDK programming reference (available in the Library section) and do a search on PIUnitBatchSearch, you should find the description on how to use this function and also an example (in VB) on it.

           

          From the search result, you can link back to the PIBatch that the unitbatches are part of.

            • Re: Search for batches in Excel VBA by unit
              mmulder6

              Thanks Han for your reply,

               

              this worked to a certain extend. I am now indeed able to get the batches from a specific unit. I can't figure out however how to get a result for multiple units; we have multiple similar reactors running batches and I want to have an overview of the batches over all these reactors, but not from our mixers.

               

              When I use the Module Database to search for unit batches I can enter Reactor* as a search option. However, this is not available within VBA.

               

              ****edited****

               

              I have found it

               

              ; it all had to do with the location within the Module Database I did the search. When selecting the root of the MDB I had more options then when selecting a unit. The solution was to use the moduleDB object instead of the module object. The PIUnitBatchSearch on a moduleDB object does have the option for a ModuleNameMask