2013-06-24 81 views
0

我需要以编程方式将Microsoft Word 2010文档保存为使用.net(最好是VB)的TIFF图像。要通过Word 2010手动执行此操作,请单击“打印”,选择“传真”作为打印机,然后选择“打印到文件”。在此之后,我点击“打印”,显示“另存为”对话框,并将文件类型设置为“所有文件”,然后输入扩展名为“tiff”的文件名。这样做会将Word文档保存为TIFF。有人可以帮助我通过VB.net做到这一点吗?任何帮助将不胜感激。.net将docx文件转换为tiff

回答

0

您可以通过使用Microsoft Windows提供的标准“传真”驱动程序以编程方式将Word文档转换为TIFF。此工作的关键是确保OutputFileName具有“.tiff”的扩展名以下是示例代码(VB.net & Word 2010):

Dim objWdDoc As Word.Document 
Dim objWord As Word.Application 
Dim sDesktop As String = _ 
    Environment.GetEnvironmentVariable("userprofile") & "\Desktop\" 

objWord = CreateObject("Word.Application") 
objWdDoc = objWord.Documents.Open(sDesktop & "testdocument.doc") 
objWord.Visible = True 

'Select Printer 
objWord.ActivePrinter = "Fax" 
'Print to Tiff 
objWdDoc.PrintOut(Range:=WdPrintOutRange.wdPrintAllDocument, _ 
         OutputFileName:=sDesktop & "test.tiff", _ 
         Item:=WdPrintOutItem.wdPrintDocumentContent, _ 
         PrintToFile:=True) 
'Close Document 
objWdDoc.Close() 
'Close Word 
objWord.Quit() 
'General Cleanup 
objWdDoc = Nothing 
objWord = Nothing