![]() |
#1
|
|||
|
|||
![]()
Hi!
I need to convert multiple .doc files to .docx. I found this code on How to batch convert .doc format files to .docx in Word? Code:
Sub ConvertDocToDocx() 'Updated by ExtendOffice 20181128 Dim xDlg As FileDialog Dim xFolder As Variant Dim xFileName As String Application.ScreenUpdating = False Set xDlg = Application.FileDialog(msoFileDialogFolderPicker) If xDlg.Show <> -1 Then Exit Sub xFolder = xDlg.SelectedItems(1) + "\" xFileName = Dir(xFolder & "*.doc", vbNormal) While xFileName <> "" Documents.Open FileName:=xFolder & xFileName, _ ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _ PasswordDocument:="", PasswordTemplate:="", Revert:=False, _ WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _ wdOpenFormatAuto, XMLTransform:="" ActiveDocument.SaveAs xFolder & Replace(xFileName, "doc", "docx"), wdFormatDocumentDefault ActiveDocument.Close xFileName = Dir() Wend Application.ScreenUpdating = True End Sub It does convert .doc files to .docx, but the problem is it does not stop when all .doc files in a folder are converted. Instead, it keeps running and converting .docx to .docxx and .docxx to .docxxx... I'd like to know why this is happening and what is wrong with the code. |
Tags |
convert doc to docx |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Converting DOCX files to plain text preserving (hanging) indents | jsampson45 | Word | 1 | 01-14-2022 11:20 PM |
Merge a .docx into a table in existing .docx | MarkAtTheBeach | Word Tables | 3 | 10-26-2018 12:55 PM |
![]() |
jimdevo17 | Word | 1 | 01-14-2011 08:17 PM |
![]() |
ding dong | Word | 3 | 11-01-2009 12:43 PM |
Converting a Docx file to a Dictionary file | geoffatmhg | Word | 0 | 02-08-2009 04:00 PM |