Prod.: Engine, ver.: 6, ID: 60000432, HowTo : I want a way to search the Document for inserts that have a certain Block.

HowTo : I want a way to search the Document for inserts that have a certain Block.

Article60000432
TypeHowTo
ProductEngine
Version6
Date Added2/26/2008
Submitted byPeter Chanios
Keywords

Subject

I want a way to search the Document for inserts that have a certain Block.

Summary

I want a way to search the whole Document for inserts that have a certain Block.

Solution

You can try a code like :


vdFramedControl.BaseControl.ActiveDocument.Prompt("Block name to search:");
string blockname = vdFramedControl.BaseControl.ActiveDocument.ActionUtility.getUserString();
vdFramedControl.BaseControl.ActiveDocument.Prompt(
null);
if (blockname == null) return;
vdBlock blk = vdFramedControl.BaseControl.ActiveDocument.Blocks.FindName(blockname);
if (blk == null) return;

//search all vdPrimaries that are document register with handle != 0
vdSelection set = new vdSelection();//create a selection to hold the items
vdPrimariesList list = vdFramedControl.BaseControl.ActiveDocument.GetPrimaries(true);
foreach (vdPrimary var in list)
{
vdInsert test = var as vdInsert;
if (test == null) continue;
if (!object.ReferenceEquals(test.Block, blk)) continue;
set.AddItem(test,
false, vdSelection.AddItemCheck.Nochecking);
}