简体   繁体   English

DOC到XPS文件文件

[英]DOC TO XPS FILE DOCUMENT

I just wanted to know how can I convert my document .doc path to xps file document. 我只是想知道如何将我的文档.doc路径转换为xps文件文档。

If anyone can help I would be glad to know the code in VB.NET since I googled it already but unfortunately I can't find best answer to my question. 如果有人可以提供帮助,我将很高兴知道VB.NET中的代码,因为我已经在Google中对其进行了搜索,但不幸的是,我找不到我问题的最佳答案。

Thank you 谢谢

I did this using the following code in a console application. 我是在控制台应用程序中使用以下代码完成此操作的。 You'll need to reference the Microsoft.Office.Interop.Word assembly (version 12 on later for the ability to generate XPS files) and import the namespace. 您将需要引用Microsoft.Office.Interop.Word程序集(稍后会介绍版本12,以生成XPS文件)并导入名称空间。

The code in VB is: VB中的代码是:

Option Explicit On

Module Module1

Sub Main()
    Dim word As _Application
    Dim doc As _Document

    word = New Application
    doc = word.Documents.Open("C:\test.doc")
    doc.SaveAs("C:\test.xps", WdSaveFormat.wdFormatXPS)
    word.Quit()
End Sub

End Module

And in C#: 在C#中:

using Microsoft.Office.Interop.Word;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            _Application word = new Application();
            _Document doc = word.Documents.Open(@"C:\test.doc");
            doc.SaveAs(@"C:\test.xps", WdSaveFormat.wdFormatXPS);
            word.Quit();
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM