none
Problem with WdSaveFormat RRS feed

  • Question

  • I have used this code to convert a Word97-2003 file format to Word 2010 docx format. But It results in slight changes

    First I tried this code.

    object fileFormat = MSWord.WdSaveFormat.wdFormatXMLDocument;
    Document = oWord.Documents.Open(tempDocFile); // open the newly created .doc file
    Document.SaveAs(docxFile, fileFormat); // convert the .doc file into .docx

    It changed the top line to this

    object fileFormat = MSWord.WdSaveFormat.wdFormatXMLDocument;

    and the result was still the same. Can someone help me with this?

    Adeel

    Tuesday, August 14, 2012 2:32 PM

Answers

  • "maverick786us" wrote in message news:5d7ba58d-9503-4d01-8e7e-780e3a51d461@communitybridge.codeplex.com...
    Recording a Macro is fine. But how can I see the parameter that is passed when I manually save a file?  

     
     
    Reviewing the recorded lines of code (in the Visual Basic Editor, Alt+F11) should help.

    Stefan Blom, Microsoft Word MVP
    • Marked as answer by maverick786us Tuesday, August 21, 2012 12:22 PM
    Tuesday, August 21, 2012 12:01 PM

All replies

  • Slight changes do occur as a result of changing between .doc and .docx. Could you tell us more about them? Maybe people can judge whether what you're experiencing is normal.

    It may be worth trying calling the Convert method, and then saving....I've never used it.

    Tuesday, August 14, 2012 6:36 PM
  • When I save it manually it remains the same. But the same document which I saved programmatically it changed I will demonstrate you with these 2 examples.

    This first document is the one which converted manually by opening it in Word 2010 and saving it using Save As to convert into docx format.

    2) And when I converted the same document prorgammatically there was one line that was on top of the paragraph now moved on to bottom.


    Adeel

    Thursday, August 16, 2012 4:07 AM
  • Slight changes do occur as a result of changing between .doc and .docx. Could you tell us more about them? Maybe people can judge whether what you're experiencing is normal.

    It may be worth trying calling the Convert method, and then saving....I've never used it.


    Which convert method? The link provided by you doesn't work

    Adeel

    Thursday, August 16, 2012 6:13 AM
  • document.Convert. Link still works for me, but it's good to know...I shouldn't assume it works for everyone.

    Apart from suggesting you try document.Convert, I really don't know what to say. It's bizarre. Hopefully someone else can help.

    Edit: Probably also worth trying wdFormatDocumentDefault, which for 2007 and later will be DOCX.

    Your questions are getting harder to answer.

    • Edited by JosephFox Thursday, August 16, 2012 12:15 PM
    Thursday, August 16, 2012 12:01 PM
  • Previously I tried wdFormatDocumentDefault. But it work so I changed to wdFormatXMLDocument. :(

    Can you provide me your email address? I can provide you my source code.


    Adeel

    Thursday, August 16, 2012 12:52 PM
  • Sure, it's joefox06 -at- gmail -dot- com. But, like I said, I'm kind of out of ideas. Except before calling 'SaveAs' calling 'Convert'.
    Thursday, August 16, 2012 1:05 PM
  • Hi Adeel

    Have you tried recording a macro when saving as manually, to see what parameters Word thinks should be used?


    Cindy Meister, VSTO/Word MVP

    Sunday, August 19, 2012 4:51 PM
    Moderator
  • Hi Adeel

    Have you tried recording a macro when saving as manually, to see what parameters Word thinks should be used?


    Cindy Meister, VSTO/Word MVP


    Never tried it. Don't know how to do that

    Adeel

    Tuesday, August 21, 2012 5:34 AM
  • To record a macro, click the Record Macro button on the Developer tab (Word 2007/2010).

    Stefan Blom, Microsoft Word MVP
    Tuesday, August 21, 2012 10:02 AM
  • Recording a Macro is fine. But how can I see the parameter that is passed when I manually save a file?

    Adeel

    Tuesday, August 21, 2012 11:01 AM
  • "maverick786us" wrote in message news:5d7ba58d-9503-4d01-8e7e-780e3a51d461@communitybridge.codeplex.com...
    Recording a Macro is fine. But how can I see the parameter that is passed when I manually save a file?  

     
     
    Reviewing the recorded lines of code (in the Visual Basic Editor, Alt+F11) should help.

    Stefan Blom, Microsoft Word MVP
    • Marked as answer by maverick786us Tuesday, August 21, 2012 12:22 PM
    Tuesday, August 21, 2012 12:01 PM
  • Hi Adeel

    Alt+F11 to open the macro editor. In the "Project" window look for the "Normal" project. Open the "Modules" folder and look for the entry "NewMacros". Double-click on that and it should open the "code page" in the code window. Your recorded macro should be there.

    It will be Word's native VBA code, but since that uses named parameters you should be able to work out what Word is using. Keep in mind that Word will not supply the fully qualified Enums, just the enumeration it uses. For use in .NET you'll need to supply the full qualification.

    Where Word passes an "empty" parameter, in C# you should pass System.Type.Missing.


    Cindy Meister, VSTO/Word MVP

    Tuesday, August 21, 2012 3:00 PM
    Moderator
  • And don't leave us in suspense, Adeel! If you worked out how to get it to save accurately (I wonder if you have because of the marked answer) I'd like to know how. You might get some deserved points, too. And points mean....Prizes? No. (British radio show reference). They mean nothing. But we'd like to know.
    Tuesday, August 21, 2012 8:26 PM
  • And don't leave us in suspense, Adeel! If you worked out how to get it to save accurately (I wonder if you have because of the marked answer) I'd like to know how. You might get some deserved points, too. And points mean....Prizes? No. (British radio show reference). They mean nothing. But we'd like to know.

    I haven't tried it yet, I will let you know the results. Thanks

    Adeel

    Wednesday, August 22, 2012 5:13 AM