• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA code to convert doc to docx

sn152

Member
Hi All,

I have around 400 .doc files in a path to be converted in to .docx. Is there a way to do this using VBA? Please help. Thanks!
 
Hi,

This is the code that I used. But i am getting an error. Activex component can't find the object.

Code:
Dim fd As FileDialog 
Dim strFolder As String 
Dim strDoc As String 
Dim DoctoConvert As Document 
Set fd = Application.FileDialog(msoFileDialogFolderPicker) 
With fd 
    .Title = "Select the folder into which the documents will be saved."
    If .Show = -1 Then 
        strFolder = .SelectedItems(1) & "\" 
    Else 
        MsgBox "The documents will be saved in the default document file location."
        strFolder = "" 
    End If 
End With 
strDoc = Dir$(strFolder & "*.doc") 
Do While strDoc <> "" 
    Set DoctoConvert = Documents.Open(strFolder & strDoc) 
    With DoctoConvert 
        .SaveAs strFolder & "Processed\ & strDoc & "x", wdFormatDocumentDefault
        .Close 
    End With 
    strDoc = Dir 
Loop
[\code]
 
Back
Top