启动应用程序以在注释位置打开 docx
Start application to open docx in a comment location
是否可以使用 OpenXml API 在特定位置打开文档文件,例如在特定评论位置,使用默认应用程序打开 .docx 文件(或其他应用程序如果指定)?我知道您可以使用 Microsoft.Office.Interop.Word
打开 word 文件或 Process.Start
,但我需要在特定位置打开文档。
这是不可能的。以下 MSDN 论坛主题中给出的解释:
As far as I know, you could not open a word application with Open XML
SDK, Open XML SDK is used to operate the data which stored in the
file. I suggest you use Word automation to open a word file.
I think you could create a bookmark named as “B1” in the position of
the comment, you then use
“word.Selection.GoTo(WdGoToItem.wdGoToBookmark,Type.Missing,Type.Missing,"B1");”
to go to the comment after you open the file. A simple code as below:
public static void goToBookMark()
{
Word.Application word = new Word.Application();
word.Documents.Open(@"D:\OfficeDev\Word\Edward.docm",true);
word.Visible = true; word.Selection.GoTo(WdGoToItem.wdGoToBookmark,Type.Missing,Type.Missing,"B1");
}
For more information about Selection.GoTo, you could refer the link
below:
Selection.GoTo method: https://msdn.microsoft.com/en-us/library/office/microsoft.office.interop.word.selection.goto(v=office.15).aspx
是否可以使用 OpenXml API 在特定位置打开文档文件,例如在特定评论位置,使用默认应用程序打开 .docx 文件(或其他应用程序如果指定)?我知道您可以使用 Microsoft.Office.Interop.Word
打开 word 文件或 Process.Start
,但我需要在特定位置打开文档。
这是不可能的。以下 MSDN 论坛主题中给出的解释:
As far as I know, you could not open a word application with Open XML SDK, Open XML SDK is used to operate the data which stored in the file. I suggest you use Word automation to open a word file.
I think you could create a bookmark named as “B1” in the position of the comment, you then use “word.Selection.GoTo(WdGoToItem.wdGoToBookmark,Type.Missing,Type.Missing,"B1");” to go to the comment after you open the file. A simple code as below:
public static void goToBookMark() { Word.Application word = new Word.Application(); word.Documents.Open(@"D:\OfficeDev\Word\Edward.docm",true); word.Visible = true; word.Selection.GoTo(WdGoToItem.wdGoToBookmark,Type.Missing,Type.Missing,"B1"); }
For more information about Selection.GoTo, you could refer the link below:
Selection.GoTo method: https://msdn.microsoft.com/en-us/library/office/microsoft.office.interop.word.selection.goto(v=office.15).aspx