file not save as a .docx file

Jan 15, 2016 at 7:17 AM
Edited Jan 15, 2016 at 7:18 AM
I try to open a docx file, search and replace some text and save into a new file. For some reason, the new file I save as a "filenam.docx" but for some reason its not in docx format? Its in .doc format. This because the file size I generated is the same as a .doc file size.
I been using the method .SaveAs("filenam.docx").

For example, the file size generated is 60Kb. I manually open the file in MS word and do a save as doc (I get 60Kb) but when I try to save as docx, it compress to 40Kb. So that mean from the program(novacode) I use the SaveAs("filenam.docx") method, even thou the filename is in .docx, its not save as one? or I missing something somewhere?

I'm both new to coding and also the docx project. So I apologize if its a simple or stupid error on my part.
Hope you able to help me. Thanks
Developer
Jan 15, 2016 at 7:29 AM
So you're just basing the format on file size? You shouldn't. It's not the same and it's impossible for DocX to save as .doc.

Around august there was a patch supplied with a fix by SomeOtherDevGuy
  • Change for DocX that turns on zip compression for the parts of the doc (created docs are as small as re-saved versions from word now)
Maybe it's not covering all angles. But it's for sure saving as DocX.
Marked as answer by MadBoy on 1/15/2016 at 12:37 AM
Jan 15, 2016 at 7:43 AM
Thanks for the fast reply. Well, I did manually open in MS word and then save as a .docx format, it did seem smaller. and the same size when I save as .doc.
That why its confused me. Thanks for the clarification.
I will try the new patch to see will it save into a smaller fize size.
Thanks alot for the help.
Developer
Jan 15, 2016 at 7:45 AM
If you're not using the newest version (sources or binary) then that must be the reason for wrong file size. However you can check if .docx is proper format by simply changing .docx to .zip extension and unpacking it. It should be possible. And in .doc format it shouldn't.
Jan 15, 2016 at 7:49 AM
No, not using the latest version. Will try it now.
Awesome, I certainly didnt know about the changing to .zip extension stuff. Learn something new everyday :)
Thanks alot again.
Developer
Jan 15, 2016 at 7:51 AM
This is actually how you can compare the difference between 2 files. So you can check your 60KB file and 40KB file, both in docx format. Unpack them and compare file structure/file content and see how it was handled and what changed. This way you can learn the structure and some day give us some code with new features ;)