显示word doc的问题。使用printpreview对话框 [英] Issue displaying word doc. Using printpreview dialog

查看:64
本文介绍了显示word doc的问题。使用printpreview对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个程序,根据用户选择使用FolderDialog合并word文档,然后组合按钮,这是使用的合并代码示例:



  private   void  combineButton_Click(对象 sender,EventArgs e)
{
if (sourceFiles!= null && sourceFiles.Length > 0
{
string fileDate = DateTime.Now.ToString( dd -MM-YY);
string fileTime = DateTime.Now.ToString( HH.MM.SS);
string outcomeFolder = outputFolder;
string outputFile = 组合文件夹 + fileDate + @ + fileTime + 。docx;
string outputFileName = Path.Combine(outcomeFolder,outputFile);

MsWord.Merge(sourceFiles,outputFileName, true );





我正在尝试做的是使用printDialog,显示这个组合的单词doc,列为outputFileName - 但是由于文件路径根据用户输入的不同而出现.doc时遇到困难。理想情况下,该程序应该像



  private   void  printTest_Click( object  sender,EventArgs e)
{
printPreviewDialog1.Document = printDocument1;

// outputFileName是合并文档和文件路径
printdocument1 = outputFileName

printPreviewDialog1.ShowDialog(outputFileName);

}



欢迎任何建议或意见 - 谢谢!



我尝试了什么:



尝试使用.txt文件的在线建议,但是很难这样做。

解决方案

您无法使用PrintPreview控件显示Word文档。它不知道如何解释或呈现Word文档。



您必须使用Word互操作和​​Word中的阅读视图来显示新文档。

i currently have a program that merges word documents depending on user selection using a FolderDialog and then combine button, this is a sample of the combine code used:

private void combineButton_Click(object sender, EventArgs e)
    {
        if (sourceFiles != null && sourceFiles.Length > 0)
        {
            string fileDate = DateTime.Now.ToString("dd-MM-yy");
            string fileTime = DateTime.Now.ToString("HH.mm.ss");
            string outcomeFolder = outputFolder;
            string outputFile = "Combined Folder " + fileDate + " @ " + fileTime + ".docx";
            string outputFileName = Path.Combine(outcomeFolder, outputFile);

            MsWord.Merge(sourceFiles, outputFileName, true);



what I'm trying to do is using printDialog, display this combined word doc, which is listed as "outputFileName" - However i am having difficulties having the .doc appear as the file path varies depending on user input. Ideally the program should work like

private void printTest_Click(object sender, EventArgs e)
    {
        printPreviewDialog1.Document = printDocument1;

     // outputFileName is the merged document and filepath
        printdocument1 = outputFileName 

        printPreviewDialog1.ShowDialog(outputFileName);

    }


any suggestions or advice would be welcome - thank you!

What I have tried:

tried using online advice with .txt files, however struggled to do so.

解决方案

You cannot use the PrintPreview control to show a Word document. It has no idea how to interpret nor render a Word document.

You have to use Word interop and the Reading view in Word to show the new document.


这篇关于显示word doc的问题。使用printpreview对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆