ActiveDocument.FullName
(1)
SaveAllAsDOC
(1)
Excel
(1)
Word
(1)
WdPromptToSaveChanges
(1)
WdDoNotSaveChanges
(1)
Documents.Close
(1)
Documents.Count
(1)

Programmatical conversion of docx into doc

Asked By Nataliya Yevdoshenk
04-Dec-07 04:51 AM
We need to convert programmatically docx files into doc (xlsx into xls, pptx
into ppt) server side, on-the-fly. Is there some converter component
avalable? The target platform is windows (xp/2003/vista). The component
should be DLL/COM in order to be used from VB6 code.

I cannot comment for Excel,and PP, but for Word the following should do the

Asked By Graham Mayor
04-Dec-07 05:34 AM
I cannot comment for Excel,and PP, but for Word the following should do the
trick.

Sub SaveAllAsDOC()
Dim strFileName As String
Dim strDocName As String
Dim strPath As String
Dim oDoc As Document

With Dialogs(wdDialogCopyFile)
If .Display <> 0 Then
strPath = .Directory
Else
MsgBox "Cancelled by User"
Exit Sub
End If
End With

If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
If Left(strPath, 1) = Chr(34) Then
strPath = Mid(strPath, 2, Len(strPath) - 2)
End If
strFileName = Dir$(strPath & "*.docx")

While Len(strFileName) <> 0
Set oDoc = Documents.Open(strPath & strFileName)

strDocName = ActiveDocument.FullName
intPos = InStrRev(strDocName, ".")
strDocName = Left(strDocName, intPos - 1)
strDocName = strDocName & ".doc"
oDoc.SaveAs FileName:=strDocName, _
FileFormat:=wdFormatDocument
oDoc.Close SaveChanges:=wdDoNotSaveChanges
strFileName = Dir$()
Wend
End Sub


--
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org

Programmatical conversion of docx into doc

Asked By NataliyaYevdoshenk
04-Dec-07 07:22 AM
Thank you! this helped!
Post Question To EggHeadCafe