I am trying to automate word 2003 to save a doc file as docx (I have the
converter installed). I am actually using C# but I think the question would
equally apply to all environments
according to the documentation for word 2007, FileFormat parameter should be
set to wdFormatXMLDocument which has the value 12. However, this did not
work for me.
is there any way to get this to work for word 2003?
Andy
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
"Andy Fish" <ajf...@blueyonder.co.uk> wrote in message
news:Om$4dUZ6H...@TK2MSFTNGP02.phx.gbl...
"Doug Robbins - Word MVP" <d...@REMOVECAPSmvps.org> wrote in message
news:eHFysua6...@TK2MSFTNGP02.phx.gbl...
If Application.Version <> 12 Then
ActiveDocument.SaveAs FileName:="filename.docx", FileFormat:=109
Else
ActiveDocument.SaveAs FileName:="filename.docx", FileFormat:=12
End If
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
BTW can you tell me where you got the value 109 from? I can't find it in any
documentation
Andy
"Graham Mayor" <gma...@REMOVETHISmvps.org> wrote in message
news:OvCfoSg...@TK2MSFTNGP06.phx.gbl...
"Graham Mayor" <gma...@REMOVETHISmvps.org> wrote in message
news:eUyxyNi...@TK2MSFTNGP06.phx.gbl...
"Graham Mayor" <gma...@REMOVETHISmvps.org> wrote in message
news:OvCfoSg...@TK2MSFTNGP06.phx.gbl...
With external converters (which is what the docx converter is implemented
as) the number to use for the SaveAs will vary from PC to PC depending on
what other converters are also installed.
If you want to have code which will correctly Save As docx on any PC, then
you need to dynamically find the number to use for the SaveAs command. This
can be found by reading the SaveFormat property of the appropriate
FileConverter object.
The following macro (adapted from one in the VBA Help) lists all the file
converters on your PC, give the class name, friently name, and the
SaveFormat number.
Sub FileConverterList()
Dim cnvFile As FileConverter
Dim docNew As Document
'Create a new document and set a tab stop
Set docNew = Documents.Add
docNew.Paragraphs.Format.TabStops.Add _
Position:=InchesToPoints(3)
'List all the converters in the FileConverters collection
With docNew.Content
.InsertAfter "Class" & vbTab & "Name" & vbTab & "Number"
.InsertParagraphAfter
For Each cnvFile In FileConverters
If cnvFile.CanSave = True Then
.InsertAfter cnvFile& vbTab & cnvFile.FormatName & vbTab & _
cnvFile.SaveFormat
.InsertParagraphAfter
End If
Next
.ConvertToTable
End With
End Sub
From running this, it is possible to deduce that the class name we are
interested in is "Word12"
Therefore, in order reliably get the save format number, use this function
Function GetSaveFormat(sClassname As String) As Long
Dim cnvFile As FileConverter
For Each cnvFile In FileConverters
If cnvFile.ClassName = sClassname Then
If cnvFile.CanSave = True Then
GetSaveFormat = cnvFile.SaveFormat
Exit Function
End If
End If
Next cnvFile
End Function
To use the function to save a document as docx, proceed as follows
Dim iSaveFormat As Long
iSaveFormat = GetSaveFormat("Word12")
If iSaveFormat = 0 Then
MsgBox "Word 2007 file converter is not installed"
Else
ActiveDocument.SaveAs FileName:="filename.docx", FileFormat:=iSaveFormat
End If
I am VB ignorant and was looking for a way to save doc in txt format through
a call to a batch file - so I can call it from within Java.
Appreciate any help.
What would be the code/Fileformat to change the document to be saved as an
Office 2003 document?
Thanks ahead of time,
Mary
How can I open a docx file when I have Microsoft word 2003
Thanks for the forum. I am trying to save a document that has been created
in word 2003. I believe it is initially a .RTF file and we want to then save
it as a word 2000 .doc. Without going into much detail about why, we have
noticed that the new 2003 files when converted from .RTF to .doc increase the
size of the file muich more that 2000 did. One of our apps. do not like it.
I really like the idea Graham provided for what I am trying to accomplish.
However, I am not sure what I should change. I am guessing we need to make a
change at the " wdFormatDocumentXX "?
Regards,
Kevin
There is no difference in the file format of files created in any of the
following versions and you cannot save a document in Word 2000 format as
there is no such thing.
Word 97
Word 2000
Word XP (2002)
Word 2003
If you are using Word 2003, the command to save the document as a Word
document (the format used for Word 97-2003) is ActiveDocument.SaveAs
FileName:="filename.doc", wdFormatDocument
I do not know where the "initially a .RTF file" comes into the picture.
However, if you did want to save in that format, you would use
ActiveDocument.SaveAs FileName:="filename.rtf", wdFormatRTF
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Kevin T." <Kevin T.@discussions.microsoft.com> wrote in message
news:38FFCA31-1DA7-4F25...@microsoft.com...