Word document signing for multiple docments RRS feed

  • Question

  • Hi,

    I am trying to sign multiple documents using code given below. Even after opening all the documents before signing,

    i needed to pass pin for every the documents. But when i open all the documents manually and sign them it prompts for pin only once for very first document. So how can i achieve the same behavior via code ?? If i am mistaking anywhere plz correct me. thanks! 

    foreach (Shell32.FolderItem item in items) { if (Equals(item.Type.ToLower(),"microsoft word document")) { selected.Add(item.Path); try { object missing = System.Reflection.Missing.Value; // // create an instance of word application // Word.Application appl = new Word.Application(); // // opens the document clicked // Word.Document document = appl.Documents.Open(item.Path, ReadOnly: false, Visible: false); // docs is an array list docs.Add(document); //document.Close(ref saveChanges, ref missing, ref missing); //appl.Quit(ref missing, ref missing, ref missing); // //return true; } catch (Exception e) { MessageBox.Show("Incorrect Path Specified"); } } } foreach (Word.Document document in docs) { //MessageBox.Show(document.FullName); document.Activate(); Office.Signature sig = document.Signatures.AddNonVisibleSignature(sigID); document.Signatures.Commit(); }

    Friday, July 18, 2014 12:53 PM


  • Hi Lakshay,

    The code below doesn't work for me:

    Office.Signature sig = document.Signatures.AddNonVisibleSignature(sigID);

    Which kind of project are you using? Windows form application or Word add-in?

    Is there any reference we need to add so that the code will work fine?

    Would you mind providing a workable sample for us to reproduce this issue?

    According to your description, you want to open multiple documents and sign them. Have you tried the code below in the first loop?

    Word.Document document = appl.Documents.Open(item.Path, ReadOnly: false, Visible: false);
    Office.Signature sig = document.Signatures.AddNonVisibleSignature("");

    In addition, since you open multiple documents with invisible, I would suggest you closing these documents and making the application quit in the end.

    Hope this helps.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, July 21, 2014 6:15 AM