How to specify the SaveAs Format parameter WORD Automation
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: How to specify the SaveAs Format parameter WORD Automation

Hybrid View

  1. #1
    Join Date
    Apr 2005
    Posts
    78

    Question How to specify the SaveAs Format parameter WORD Automation

    Hi,

    Im wanting to use WORD automation to save a WORD doc in a different format say text or unicode etc.

    I have created the files from create class from typelib etc, can create my doc etc.

    But I want to specify the parameter for the format in the SaveAs method for the document object.

    In the documentation it is of type wdsaveformat
    http://msdn.microsoft.com/en-us/libr...aveformat.aspx

    In the SaveAs method of the document object it is just variant and an enum of type wdsaveformat
    is not present in any of the files created from the typelib.

    How can I specify the format parameter for the saveas method of the document object?

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,604

    Re: How to specify the SaveAs Format parameter WORD Automation

    Quote Originally Posted by PRMARJORAM View Post
    ... In the SaveAs method of the document object it is just variant and an enum of type wdsaveformat
    is not present in any of the files created from the typelib.
    Uhmm... and how about WdSaveFormat enumeration?
    Victor Nijegorodov

  3. #3
    Join Date
    Apr 2005
    Posts
    78

    Smile Re: How to specify the SaveAs Format parameter WORD Automation

    Quote Originally Posted by VictorN View Post
    Uhmm... and how about WdSaveFormat enumeration?
    Yes thats what I mean.
    In fact I found a workaround.

    When the files are created from the typelib another header file is also created with an extension.tlh so I got msword.tlh

    This contains all the enums etc referenced.

    But, if I include this file directly, get lots of compilations errors. I not need to though as within this file you can find the enumeration values you need: e.g;

    enum WdSaveFormat
    {
    wdFormatDocument = 0,
    wdFormatDocument97 = 0,
    wdFormatTemplate = 1,
    wdFormatTemplate97 = 1,
    wdFormatText = 2,
    wdFormatTextLineBreaks = 3,
    wdFormatDOSText = 4,
    wdFormatDOSTextLineBreaks = 5,
    wdFormatRTF = 6,
    wdFormatUnicodeText = 7,
    wdFormatEncodedText = 7,
    wdFormatHTML = 8,
    wdFormatWebArchive = 9,
    wdFormatFilteredHTML = 10,
    wdFormatXML = 11,
    wdFormatXMLDocument = 12,
    wdFormatXMLDocumentMacroEnabled = 13,
    wdFormatXMLTemplate = 14,
    wdFormatXMLTemplateMacroEnabled = 15,
    wdFormatDocumentDefault = 16,
    wdFormatPDF = 17,
    wdFormatXPS = 18,
    wdFormatFlatXML = 19,
    wdFormatFlatXMLMacroEnabled = 20,
    wdFormatFlatXMLTemplate = 21,
    wdFormatFlatXMLTemplateMacroEnabled = 22
    };

    And then in your code just create a variant object with the value you so desire: e.g.

    COleVariant covUnicodeConvert((long)7);

    then pass this as a parameter to the saveAs method.

    Thanks

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center