locked
word automation RRS feed

  • Question

  • Hi,

    I have 2 questions about using word automation here.

    1. when I use "copy to (file name) type delimited", is there any specific type for word or I can just stay with delimited?

    2. If I want to save doc to docx by using saveas(forceext(file name,"docx")), it will cause an error (incompatible issue). I can use it to save xls to xlsx but can't do this for word. any hints?

    thanks for your time

    Char

    Thursday, May 31, 2012 10:01 PM

Answers

  • Giving the document an extension of DOCX doesn't make it a DOCX. If you want to save it in the DOCX format, you need to pass the optional second parameter to SaveAs, specifying the format you want. I think the right value is 12, but you can find the list here: http://msdn.microsoft.com/en-us/library/ff839952.aspx.

    Of course, you can only save in DOCX format if you're in Word 2007 or later, or have the compatibility add-on for Word 2003.

    Tamar

    P.S. Saving an Excel workbook with an extension of XSLX doesn't make it an XSLX file, either. Same solution.

    Friday, June 1, 2012 8:14 PM
    Answerer
  • Check the workbook's FileFormat property.

    Tamar

    Thursday, June 7, 2012 8:34 PM
    Answerer

All replies

  • Hi Char,

    1. i suggest you to stay with delimited because you can open delimited file in word.

    2. give sample code for this question.


    Kalpesh


    Please "Mark as Answer" if this post answered your question. :)

    Kalpesh Chhatrala | Software Developer | Rajkot | India

    Kalpesh 's Blog

    VFP Form to C#, Vb.Net Conversion Utility

    Friday, June 1, 2012 6:20 AM
    Answerer
  • Kalpesh,

    this is the code I use to save as into another extension in word but I receive an error.

    oleApp.ActiveDocument.SaveAs(forceext(file name,"docx"))

    thanks

    Char

    Friday, June 1, 2012 7:02 PM
  • Giving the document an extension of DOCX doesn't make it a DOCX. If you want to save it in the DOCX format, you need to pass the optional second parameter to SaveAs, specifying the format you want. I think the right value is 12, but you can find the list here: http://msdn.microsoft.com/en-us/library/ff839952.aspx.

    Of course, you can only save in DOCX format if you're in Word 2007 or later, or have the compatibility add-on for Word 2003.

    Tamar

    P.S. Saving an Excel workbook with an extension of XSLX doesn't make it an XSLX file, either. Same solution.

    Friday, June 1, 2012 8:14 PM
    Answerer
  • Giving the document an extension of DOCX doesn't make it a DOCX. If you want to save it in the DOCX format, you need to pass the optional second parameter to SaveAs, specifying the format you want. I think the right value is 12, but you can find the list here: http://msdn.microsoft.com/en-us/library/ff839952.aspx.

    Of course, you can only save in DOCX format if you're in Word 2007 or later, or have the compatibility add-on for Word 2003.

    Tamar

    P.S. Saving an Excel workbook with an extension of XSLX doesn't make it an XSLX file, either. Same solution.

    How do I know the excel file made in Excel 2003 or Excel 2007?

    Sandor


    Sandor

    Thursday, June 7, 2012 12:28 PM
  • Check the workbook's FileFormat property.

    Tamar

    Thursday, June 7, 2012 8:34 PM
    Answerer