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

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 theLibrarysection) 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.