Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2007

Tip: Looking for answers? Try searching our database.

Programmatical conversion of docx into doc

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nataliya Yevdoshenko - 04 Dec 2007 09:51 GMT
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.
Graham Mayor - 04 Dec 2007 10:34 GMT
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

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

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

> 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.
Nataliya Yevdoshenko - 04 Dec 2007 12:22 GMT
Thank you! this helped!

> I cannot comment for Excel,and PP, but for Word the following should do the
> trick.
[quoted text clipped - 40 lines]
> > component avalable? The target platform is windows (xp/2003/vista).
> > The component should be DLL/COM in order to be used from VB6 code.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.