A
Andrew
Hi,
I want to programatically convert a .doc file to .docx
I am working in c# and as indicated in the subject line I am using the
Office.Interop libraries for Office 2007 (Microsoft.Office.Interop.Word.dll v
12.0.6211.1000).
I am working with code similar to the following;
object oOpenName = c:\\Temp\\DocTestOpen.doc;
object oSaveName = object oOpenName = c:\\Temp\\DocxTestSave.docx;
object oDocXFormat = Word.WdSaveFormat.wdFormatDocument;
Word.Document doc = wdApp.Documents.Open(ref oOpenName, ref missing, ref
missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref
missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref
missing, ref missing);
doc.SaveAs(ref oSaveName, ref oDocXFormat , ref missing, ref missing, ref
missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref
missing, ref missing, ref missing, ref missing, ref missing, ref missing);
I created the source .doc file (DocTestOpen.doc) using Office 2007 saving
the file as a .doc so it is a Word 97 formatted file.
When I use the WdSaveFormat.wdFormatDocument ie
object oDocXFormat = WdSaveFormat.wdFormatDocument;
I am told that the document is corrupt. Renaming the file to a .doc
extension reveals that the file was not converted and is still a .doc (office
97) format.
I also tried
object oDOCXFormat = WdSaveFormat.wdFormatXMLDocument;
Using wdFormatXMLDocument the file can be opened however Word 2007 indicates
that it is in compatibility mode and when I go 'Save As' even though the file
type list is set to .docx when I click save it prompts me to convert the
document. ie
'You are about to sae your document to one of the new file formats. .... etc
etc"
Searching the net has not revealed an obvious solution. I don't know if
this means no one else is doing this or I have missed the obvious.
Thanks,
Andrew
I want to programatically convert a .doc file to .docx
I am working in c# and as indicated in the subject line I am using the
Office.Interop libraries for Office 2007 (Microsoft.Office.Interop.Word.dll v
12.0.6211.1000).
I am working with code similar to the following;
object oOpenName = c:\\Temp\\DocTestOpen.doc;
object oSaveName = object oOpenName = c:\\Temp\\DocxTestSave.docx;
object oDocXFormat = Word.WdSaveFormat.wdFormatDocument;
Word.Document doc = wdApp.Documents.Open(ref oOpenName, ref missing, ref
missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref
missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref
missing, ref missing);
doc.SaveAs(ref oSaveName, ref oDocXFormat , ref missing, ref missing, ref
missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref
missing, ref missing, ref missing, ref missing, ref missing, ref missing);
I created the source .doc file (DocTestOpen.doc) using Office 2007 saving
the file as a .doc so it is a Word 97 formatted file.
When I use the WdSaveFormat.wdFormatDocument ie
object oDocXFormat = WdSaveFormat.wdFormatDocument;
I am told that the document is corrupt. Renaming the file to a .doc
extension reveals that the file was not converted and is still a .doc (office
97) format.
I also tried
object oDOCXFormat = WdSaveFormat.wdFormatXMLDocument;
Using wdFormatXMLDocument the file can be opened however Word 2007 indicates
that it is in compatibility mode and when I go 'Save As' even though the file
type list is set to .docx when I click save it prompts me to convert the
document. ie
'You are about to sae your document to one of the new file formats. .... etc
etc"
Searching the net has not revealed an obvious solution. I don't know if
this means no one else is doing this or I have missed the obvious.
Thanks,
Andrew