如何使用 C# 向 word 文档添加 URL 评论?

How to add URL comment to word document using c#?

这是我的代码。我可以发表评论,但我想在评论中加入 URL。 我该怎么做?

  using Microsoft.Office.Interop.Word;
  using Microsoft.Office.Core;

  private void button3_Click(object sender, EventArgs e)
    {
        // Open a doc file.
        Microsoft.Office.Interop.Word.Application application = new Microsoft.Office.Interop.Word.Application();
        Microsoft.Office.Interop.Word.Document document = application.Documents.Open(@"e:\temp3.docx");
        object comment = "www.google.com" + Environment.NewLine;
        object missing = System.Reflection.Missing.Value;
        Microsoft.Office.Interop.Word.Comment var = document.Comments.Add(document.Words[1], comment);
        try {
            document.Hyperlinks.Add(var.Range,ref missing,ref missing,ref missing,ref missing,ref missing);
        }
        catch (Exception ex)
        { MessageBox.Show(ex.ToString()); }
        document.Close();
        application.Quit();
    }

但结果是这样

And bad parameter exception in Hyperlink.add

// Insert a hyperlink to the Web page.
object oAddress = "http://www.microsoft.com";
object oRange = wrdSelection.Range;
document.Hyperlinks.Add(oRange, ref oAddress, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
    private void button3_Click(object sender, EventArgs e)
    {
        // Open a doc file.
        Microsoft.Office.Interop.Word.Application application = new Microsoft.Office.Interop.Word.Application();
        Microsoft.Office.Interop.Word.Document document = application.Documents.Open(@"e:\temp3.docx");
        object comment = "www.google.com" + Environment.NewLine;
        object missing = System.Reflection.Missing.Value;
        Microsoft.Office.Interop.Word.Comment var = document.Comments.Add(document.Words[1], comment);
        try {
            document.Hyperlinks.Add(var.Range,ref comment,ref missing,ref missing,ref missing,ref missing);
        }
        catch (Exception ex)
        { MessageBox.Show(ex.ToString()); }
        document.Close();
        application.Quit();
    }

在 HyperLinks.Add 而不是 ref 评论中,我把 ref missing .