none
Automatic Conversion: Office File to XPS RRS feed

  • Question

  • Hi,

    I need to automatically convert Word, Excel, or PowerPoint file to XPS file (by printing it by XPS Document Writer). If the user has the Office product, I think UI Automation can be used. But, if he/she does not have the product but only has the OfficeViewer, what is the best interface to choose for the automatic conversion ?

    Thanks a lot in advance.

    Best regards,

    Tak

    Sunday, October 23, 2011 4:12 PM

Answers

  • Hi Tak

    Can the Microsoft Office Viewer save in other file formats? Does it have a Save As command? I would be very surprised if it did, because it was designed only to allow viewing documents, not changing or editing.

    The only other thing I can think of would be if you could offer the Word Automation Services on Sharepoint 2010 to these people. See

    http://msdn.microsoft.com/en-us/library/ee558830.aspx


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Bruce Song Wednesday, November 2, 2011 6:04 AM
    Sunday, October 30, 2011 3:55 PM
    Moderator
  • Thank you, Cindy,

    > Can the Microsoft Office Viewer save in other file formats? Does it have a Save As command? I would be very > surprised if it did, because it was designed only to allow viewing documents, not changing or editing.

    No, it cannot and it does not. I'm going to "print" an office file by specifying the XPS Document Writer as the printer, as I wrote in the beginning. I believe this would be the only way to achieve the conversion.

    Tak

    • Marked as answer by Bruce Song Wednesday, November 2, 2011 6:04 AM
    Monday, October 31, 2011 1:01 AM

All replies

  • Hi Tak,

    Thank you for posting.

    As far as I know, you can save as the Word, Excel or Powerpoint file to XPS file. For example, in Word, the following macro can save as xps:

    Sub Macro2()
    '
    ' Macro2 Macro
    '
    '
        ActiveDocument.ExportAsFixedFormat OutputFileName:= _
            "C:\Users\v-bpeng\Desktop\1.xps", ExportFormat:= _
            wdExportFormatXPS, OpenAfterExport:=True, OptimizeFor:= _
            wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
            Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
            CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
            BitmapMissingFonts:=True, UseISO19005_1:=False
    End Sub

    Hope this can help you and just feel free to follow up after you have tried.


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, October 26, 2011 11:24 AM
  • Hi, Bruce.

    Thank you very much for your reply and answer. That's a great idea to use macros. Actually I have not thought about the approach. The macro approach works also in the case of OfficeViewer, right ?  I will try it shortly.

    We are developing an XPS based desktop application in which we'd like to allow the user to import Word, Excel, or PowerPoint file. In this case, the appllication should submit the macro to Word, Excel, or PowerPoint to execute the import. It would be appreciated if you could give me any C++ sample to execute the macro. Sorry that I cannot say I'm a profesional programmer. I'd also like to know if  there are anything to do to take care about security issues.

    Thank you so much.

     

    Best regards,

    Tak

    Saturday, October 29, 2011 6:09 AM
  • Hi Tak

    <<The macro approach works also in the case of OfficeViewer, right ?>>

    No, it will not. Macros cannot work in the Office viewer; no code can work inside the Office Viewer.


    Cindy Meister, VSTO/Word MVP
    Saturday, October 29, 2011 8:11 AM
    Moderator
  • Cindy,

    Thanks you for letting me know. Then, to make Office Viewer automatically convert file to XPS, shoud I use Windows interface itself by using SendKeys class, etc. from the application ?

    Regards,

    Tak

    Sunday, October 30, 2011 11:03 AM
  • Hi Tak

    Can the Microsoft Office Viewer save in other file formats? Does it have a Save As command? I would be very surprised if it did, because it was designed only to allow viewing documents, not changing or editing.

    The only other thing I can think of would be if you could offer the Word Automation Services on Sharepoint 2010 to these people. See

    http://msdn.microsoft.com/en-us/library/ee558830.aspx


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Bruce Song Wednesday, November 2, 2011 6:04 AM
    Sunday, October 30, 2011 3:55 PM
    Moderator
  • Thank you, Cindy,

    > Can the Microsoft Office Viewer save in other file formats? Does it have a Save As command? I would be very > surprised if it did, because it was designed only to allow viewing documents, not changing or editing.

    No, it cannot and it does not. I'm going to "print" an office file by specifying the XPS Document Writer as the printer, as I wrote in the beginning. I believe this would be the only way to achieve the conversion.

    Tak

    • Marked as answer by Bruce Song Wednesday, November 2, 2011 6:04 AM
    Monday, October 31, 2011 1:01 AM