Is there a way to programmatically predefine the p

2019-09-17 08:36发布

I'm creating an Excel file *.xlsx in a C#environment with Microsoft Excel Interop.

I call the signing dialog programmatically with the following commands:

    using Excel = Microsoft.Office.Interop.Excel;

    Excel.Application xlapp = null;
    xlapp = new Microsoft.Office.Interop.Excel.Application();
    Excel.Workbook xlwb = xlapp.Workbooks.Add();

    object sigID = "{00000000-0000-0000-0000-000000000000}";
    xlwb.Signatures.AddNonVisibleSignature(sigID);

The "Sign" dialog appears and the user's credentials are generally displayed as they log on to the system with them. The user is prompted for "Purpose for signing this document".

I would like to predefine the purpose. (Users would still be able to edit it, if they have a differing purpose.) Am I overseeing something I should set in the xlwb.Signatures or am I looking in the wrong place?

1条回答
我想做一个坏孩纸
2楼-- · 2019-09-17 09:17

I think this should work:

xlapp.DisplayAlerts = false;
xlwb.Signatures.AddNonVisibleSignature(sigID);
xlapp.DisplayAlerts = true;

All I'm doing above is turning off the alerts while you set the signature, and then turning them back on right after.

查看更多
登录 后发表回答