我目前在用的是Office 2010,由于前段时间要用OLE,即Word特定的位置引用Excel不同的单元格的数据,发现Word 2003格式*.doc不兼容OLE方式,所以对现有的Word 2003要全部另存为Word 2007版本以上的格式,即*.docx。由于有十几个Word 2003 版本的文件,所以感觉手动另存为Word 2007以上的版本较为费时,所以写了个VBA,也便于以后工作中的转换。
Sub Doc2Docx()
'
' Doc2Docx 宏
'
'“C:\Users\Vin\Desktop\办\夏”是要转换文件所在目录
Dim wdapp As Word.Application
Dim wddocument, currentdoc As Word.Document
Set wdapp = New Word.Application
Application.ScreenUpdating = False
ChangeFileOpenDirectory "C:\Users\Vin\Desktop\办\夏"
FileName = Dir("C:\Users\Vin\Desktop\办\夏\*.doc")
Do While FileName <> ""
Documents.Open (FileName)
ActiveDocument.SaveAs2 FileName:=Left(FileName, Len(FileName) - 4) & ".docx", FileFormat:= _
wdFormatXMLDocument, LockComments:=False, Password:="", AddToRecentFiles _
:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts _
:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False, CompatibilityMode:=14
ActiveDocument.Close
FileName = Dir()
Loop
End Sub
方法很简单,更改你所需转换的文件所在目录,将以上代码直接复制,然后运行,再按类型排序删除之前2003 版本的格式。