Programmatical conversion of docx into doc

  • Thread starter Nataliya Yevdoshenko
  • Start date
N

Nataliya Yevdoshenko

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.
 
G

Graham Mayor

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
N

Nataliya Yevdoshenko

Thank you! this helped!

Graham Mayor said:
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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top