foreach (Microsoft.Office.Core.CommandBarControl control in commandBars["View"].Controls)
{
Microsoft.Office.Core.CommandBarButton button =
control as Microsoft.Office.Core.CommandBarButton;
if (button != null)
{
button.Execute();
}
}
StringBuilder sb = new StringBuilder();
foreach (Microsoft.Office.Core.CommandBar bar in commandBars)
{
sb.Append(string.Format("CommandBar Name:{0}\r\n", bar.Name));
foreach(Microsoft.Office.Core.CommandBarControl control in bar.Controls)
{
Microsoft.Office.Core.CommandBarButton button = control as
Microsoft.Office.Core.CommandBarButton;
if(button != null)
{
sb.Append(string.Format("Button Name:{0} \r\n", button.Caption));
}
}
}
Form2 frm = new Form2();
frm.txtContent.Text = sb.ToString();
frm.Show();
short flags = (short)VisOpenSaveArgs.visOpenDocked | (short)VisOpenSaveArgs.visOpenRO;
StencilOpenEx(wndVisio.Application, flags);
//根据模具,获取属性对象集合
public List GetPropertyCollection(Visio.Shape shape)
{
List list = new List();
StencilPropertyInfo propertyInfo;
Visio.Cell shapeCell;
short shortSectionProp = (short)VisSectionIndices.visSectionProp;
if (shape != null)
{
for (short i = 0; i < shape.get_RowCount(shortSectionProp) - 1; i++ )
{
if (shape.get_CellsSRCExists(shortSectionProp, i,
(short)VisCellIndices.visCustPropsLabel, 0) != 0)
{
propertyInfo = new StencilPropertyInfo();
shapeCell = shape.get_CellsSRC(shortSectionProp, i,
(short)VisCellIndices.visCustPropsLabel);
propertyInfo.Name = VisioUtility.FormulaStringToString(shapeCell.RowNameU);
shapeCell = shape.get_CellsSRC(shortSectionProp, i,
(short)VisCellIndices.visCustPropsPrompt);
propertyInfo.Prompt = VisioUtility.FormulaStringToString(shapeCell.FormulaU);
shapeCell = shape.get_CellsSRC(shortSectionProp, i,
(short)VisCellIndices.visCustPropsFormat);
propertyInfo.Format = VisioUtility.FormulaStringToString(shapeCell.FormulaU);
shapeCell = shape.get_CellsSRC(shortSectionProp, i,
(short)VisCellIndices.visCustPropsValue);
propertyInfo.Value = VisioUtility.FormulaStringToString(shapeCell.FormulaU);
shapeCell = shape.get_CellsSRC(shortSectionProp, i,
(short)VisCellIndices.visCustPropsSortKey);
propertyInfo.Sort = VisioUtility.FormulaStringToString(shapeCell.FormulaU);
//shapeCell = shape.get_CellsSRC(shortSectionProp, i,
(short)VisCellIndices.visCustPropsType);
//propertyInfo.PropType = VisioUtility.FormulaStringToString(shapeCell.FormulaU);
//shapeCell = shape.get_CellsSRC(shortSectionProp, i,
(short)VisCellIndices.visCustPropsInvis);
//propertyInfo.InVisible = VisioUtility.FormulaStringToString(shapeCell.FormulaU);
//..
list.Add(propertyInfo);
}
}
}
return list;
}
//根据模具和属性名称,获取属性对象信息
public StencilPropertyInfo GetProperty(Visio.Shape shape, string propertyName)
{
List list = GetPropertyCollection(shape);
StencilPropertyInfo propertyInfo = null;
foreach(StencilPropertyInfo tempInfo in list)
{
if (tempInfo.Name == propertyName)
{
propertyInfo = tempInfo;
break;
}
}