Need help with macro....batch convert doc to docx including subfolders


hello,

i searched forums , able find below macro convert .doc .docx (2010 format) works in word:

sub saveallasdocx()
dim strfilename string
dim strdocname string
dim strpath string
dim odoc document
dim fdialog filedialog
dim intpos integer
set fdialog = application.filedialog(msofiledialogfolderpicker)
fdialog
    .title = "select folder , click ok"
    .allowmultiselect = false
    .initialview = msofiledialogviewlist
    if .show <> -1 then
        msgbox "cancelled user", , "list folder contents"
        exit sub
    end if
    strpath = fdialog.selecteditems.item(1)
    if right(strpath, 1) <> "\" strpath = strpath + "\"
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 & "*.doc")
while len(strfilename) <> 0
    set odoc = documents.open(strpath & strfilename)
    strdocname = activedocument.fullname
    intpos = instrrev(strdocname, ".")
    strdocname = left(strdocname, intpos - 1)
    strdocname = strdocname & ".docx"
    odoc.saveas2 filename:=strdocname, _
        fileformat:=wdformatxmldocument, _
        compatibilitymode:=14
    odoc.close savechanges:=wddonotsavechanges
    strfilename = dir$()
wend
end sub

can please modify above macro include subfolders or @ least point me in right direction? have searched , have not been able find solution.

thank you!

hello,

we have bulk conversion utility can convert multiple doc files docx files. consider using instead?

blog article: bulk convert doc docx
http://blogs.msdn.com/b/ericwhite/archive/2008/09/19/bulk-convert-doc-to-docx.aspx 

with utility, make sure the documents in subfolders dealt with, use convertsubfolders setting.

for example, add following line [folderstoconvert] section:

convertsubfolders=1


max meng
technet community support



Microsoft Office  >  Word IT Pro Discussions



Comments

Popular posts from this blog

server manager error: ADAM.events.xml could not be enumerated.

Cannot access Anywhere Access using domain name?

WMI Failure: Unable to update Local Resource Group