cregan

Help using VBA to Change BatchGroup SearchCriteria

Discussion created by cregan on Mar 4, 2020

I am trying to modify the Unit Name within the SearchCriteria of a BatchGroup object as I switch between elements of an Element Relative Display.

 

We are running older software and have not transitioned to event frames yet:

  • PI ProcessBook 2015 3.5.0.284
  • PI BatchView 3.1.4

 

Previously I would type "%ModuleContext%" within the Unit Name field, but upon transitioning from 'Modules' to 'Elements' this no longer works. If there is something as simple as this, it would solve my problem quickly. The unit name I am looking for corresponds to the active element's "Name" within properties.

 

In the absence of a non-VBA solution, I was trying to accomplish this with VBA. I know the value (Unit Name) I'm looking to change corresponds to the following (where BatchGroup1 is the target BatchGroup object):

ThisDisplay.BatchGroup1.SearchCriteria.BatchItemCriteria.AttributeMasks(2).Mask (0)

 

Given this property is read only, my research led me to believe the following would modify it:

Call ThisDisplay.BatchGroup1.SearchCriteria.BatchItemCriteria.AttributeMasks(2).InsertMask("XYZ123",0)

OR

Call ThisDisplay.BatchGroup1.SearchCriteria.BatchItemCriteria.AttributeMasks(2).RemoveMask(0)

Call ThisDisplay.BatchGroup1.SearchCriteria.BatchItemCriteria.AttributeMasks(2).InsertMask("XYZ123",0)

 

However, while both options compile and execute without error, it does not change the target 'AttributeMasks(2).Mask(0)'.

 

Any suggestions?

 

Thanks,

Cory

Outcomes