通过C#.NET显示审阅文件word
我使用C#打印项目文件word 我激活了一个文档并调用了通过C#.NET显示审阅文件word,c#,.net,C#,.net,我使用C#打印项目文件word 我激活了一个文档并调用了PrintPreview(),但它没有显示任何内容。我试图更改文档的类型视图,但它不会显示太多 我想在打印之前显示打印评论,但它不起作用:( 我的代码: void PrintFileWord(string p_strPath) { object v_objFilename = p_strPath; Microsoft.Office.Interop.Word.Application v_appAC =
PrintPreview()
,但它没有显示任何内容。我试图更改文档的类型视图,但它不会显示太多
我想在打印之前显示打印评论,但它不起作用:(
我的代码:
void PrintFileWord(string p_strPath)
{
object v_objFilename = p_strPath;
Microsoft.Office.Interop.Word.Application v_appAC = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document v_doc = new Microsoft.Office.Interop.Word.Document();
object v_objReadOnly = false;
object v_objIsVisible = true;
object v_objMissing = System.Reflection.Missing.Value;
if (v_doc.Application.WindowState == WdWindowState.wdWindowStateMaximize){
((_Document)v_doc).Close();
}
v_doc = v_appAC.Documents.Open(ref v_objFilename,
ref v_objMissing, ref v_objMissing, ref v_objMissing, ref v_objMissing,
ref v_objMissing, ref v_objMissing, ref v_objMissing, ref v_objMissing,
ref v_objMissing, ref v_objMissing, ref v_objMissing, ref v_objMissing,
ref v_objMissing, ref v_objMissing, ref v_objMissing);
v_appAC.PrintPreview = true;
v_doc.Activate();
v_doc.PrintPreview();
((_Document)v_doc).Close();
((_Application)v_appAC).Quit();
}
我希望其他人能帮我解决这个问题。您需要使应用程序可见-添加以下内容:
v_appAC.Visible = true;
PrintPreview模式可以通过设置PrintPreview属性或调用PrintPreview方法来显示-不必同时执行这两种操作
可以将代码简化为:
Microsoft.Office.Interop.Word.Application v_appAC = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document v_doc;
v_doc = v_appAC.Documents.Open(p_strPath);
v_appAC.Visible = true;
v_appAC.PrintPreview = true;
v_doc.Close();
v_appAC.Quit();
你在哪里使用v_objIsVisible?如果是我的答案解决了你的问题,那么你应该将它标记为正确-这样,如果其他人搜索类似的问题,它会突出显示为已回答。是的,我做到了:D:D