以下のコードを試しましたが、ドキュメントを開かずに署名できませんでした。証明書を開かずにドキュメントに署名することは可能ですか?
object TempFilePath = TemporaryFolder + FileTempName;
object Visible = false;
object readonlyfile = false;
try
{
object missing = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word.ApplicationClass wordapp = new
Microsoft.Office.Interop.Word.ApplicationClass();
Microsoft.Office.Interop.Word.Document wordDocument = wordapp.Documents.Open(ref
TempFilePath, ref missing,
ref readonlyfile, ref missing, ref missing,
ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing,
ref Visible, ref missing, ref missing,
ref missing, ref missing);
// wordDocument.Activate();
// object sigID = "{00000000-0000-0000-0000-000000000000}";
// wordDocument.ActiveWindow.Application.ActiveDocument.Signatures.AddSignatureLine(sigID);
// wordDocument.ActiveWindow.Application.ActiveDocument.Signatures.Commit();
SignatureSet signatureSet = wordDocument.Signatures;
Signature objSignature = signatureSet.Add();
if (objSignature == null)
{
DocumentNotSigned(item);
return false;
}
else
{
signatureSet.Commit();
object saveChanges = true;
wordDocument.Close(ref saveChanges, ref missing, ref missing);
wordapp.Quit(ref missing, ref missing, ref missing);
return true;
}