1

I'm using the Word 2007-component in C#.

I want to save the Word document as a Word97(-2003)-document, because not everyone uses Word 2007/2010.

I thought it is easy by using the following command

document.SaveAs(AFullFileName, WdSaveFormat.wdFormatDocument97);

But then the SaveAs-dialog is shown with the assumption that I want to save it as a docx-file.

SaveAs Dialog

I've noticed that the WdSaveFormat.wdFormatDocument-flag has had the same value as WdSaveFormat.wdFormatDocument97-flag. So I think I have to do more then only using those parameters in the SaveAs-command.

Can anybody help me? I would like the format to be correct and not to see the Save As dialog.

Thanks.

Adam B
  • 3,775
  • 3
  • 32
  • 42
user1531040
  • 2,143
  • 6
  • 28
  • 48
  • 1
    Weird - I just tried similar code and it worked fine for me. Is the extension in the AFullFileName parameter set to ".doc"? Can you save as Word 97 using Word interactively on the target computer? – Ian Gilroy Aug 09 '12 at 08:28

2 Answers2

0

As already suggested in comments most probably you must check that save file name, (i.e. AFullFileName argument) extension is properly set to .doc, not .docx. Word enforces that for security reasons.

Petr Abdulin
  • 33,883
  • 9
  • 62
  • 96
  • AFullFileName has an extension of .doc NOT .docx. And still the system asked if want to save it as .docx. I've checked again, AFullFileName has as extension of .doc. Please can anybody help me? – user1531040 Aug 09 '12 at 09:29
  • Can use save file in target location manually (from shown up dialog)? Are you using full path or only filename in `AFullFileName`? – Petr Abdulin Aug 09 '12 at 09:41
  • This is the contents of AFullFileName: "e:\temp\Samenvoegbestand_xyl.doc" – user1531040 Aug 09 '12 at 09:46
  • Well, will it save the file if you select desired format and enter `e:\temp\Samenvoegbestand_xyl.doc` (like this, full path with the drive letter) in save as dialog? – Petr Abdulin Aug 09 '12 at 09:52
  • Yes it will do. But the user didn't have to change into Word 97. – user1531040 Aug 09 '12 at 09:58
  • The document has a Word97 structure too. And if you save it as a docx-document. The pages will overlap each other. – user1531040 Aug 09 '12 at 09:59
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/15122/discussion-between-user1531040-and-petr-abdulin) – user1531040 Aug 09 '12 at 12:43
0

I've solve this by saving the document under another filename.

I tried to save the file as doc-file by using Word 2007. But it seems that the file can't be overwritten. I tried to change the type of Save As. I chose several times Word97-doc. But nothing was saved. And everytime the type turns back as a docx-document.

And finally when I change the filename, the document saved as a Word97-document.

user1531040
  • 2,143
  • 6
  • 28
  • 48