using corel = Corel.Interop.VGCore;
using frm = System.Windows.Forms;
//获取工具栏工具ID值
//======================================================================
//方法:打印CommandBar信息
//作用:将所有CommandBar信息全部打印出来,用于自动化调用
//======================================================================
private void GetcombarID()
{
try
{
string f = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\CDRCommandBarIDInfo.txt";
List<string> slst = new List<string>();
corel.CommandBars AA = capp.FrameWork.CommandBars;
foreach (corel.CommandBar cmdbar in AA)
{
slst.Add(cmdbar.NameLocal + "-工具栏下面的菜单项:");
foreach (corel.Control ctl in cmdbar.Controls)
{
slst.Add("\t" + ctl.ID + " -> " + ctl.Caption);
}
}
slst.Add("-------------------示例------------------");
slst.Add("Public Sub Smartspacing()");
slst.Add(" Application.FrameWork.Automation.InvokeItem; \"0ce0b6c1-eab7-4b59-9cd9-d42c1fe89195\"'矫正文本");
slst.Add(" Application.FrameWork.Automation.InvokeItem; \"4e23866f-d86f-45f8-9afd-6b84bb7cdc9a\"'添加下划线");
slst.Add(" Application.FrameWork.Automation.InvokeItem; \"4e23866f-d86f-45f8-9afd-6b84bb7cdc9a\"'删除下划线");
slst.Add("End Sub");
slst.Add("-----------------------------------------");
File.WriteAllLines(f, slst.ToArray(), Encoding.UTF8);
Process.Start("explorer", "/select," + f);
}
catch (Exception ex)
{
frm.MessageBox.Show(ex.Message);
}
}