|
楼主 |
发表于 2018-3-14 13:42
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 lioboo 于 2018-3-14 13:46 编辑
- Sub ListFilesTest()
- Application.ScreenUpdating = False
- With Application.FileDialog(msoFileDialogFolderPicker) '运行后出现标准的选择文件夹对话框
- If .Show Then myPath = .SelectedItems(1) Else Exit Sub '如选中则返回=-1 / 取消未选则返回=0
- End With
- If Right(myPath, 1) <> "" Then myPath = myPath & ""
- '返回的是选中目标文件夹的绝对路径,但除了本地C盘、D盘会以"C:"形式返回外,其余路径无""需要自己添加
- Getfd (myPath)
- Application.ScreenUpdating = True
- End Sub
- Sub Getfd(ByVal pth)
- Dim Wordapp As New Word.Application
- Dim fn As String
- Dim Wd As Document
- Set Fso = CreateObject("scripting.filesystemobject")
- Set ff = Fso.getfolder(pth)
- For Each f In ff.Files
- fn = f.Name
- Set Wd = Wordapp.Documents.Open(pth & "" & fn)
- Selection.WholeStory
- Wordapp.WordBasic.ToolsSCTCTranslate Direction:=0, Varients:=0, TranslateCommon:=0'对word的操作
- Wd.Close True
- Next f
- For Each fd In ff.subfolders
- Getfd (fd)
- Next fd
- Set Wordapp = Nothing
- Set Wd = Nothing
- End Sub
复制代码
自己研究了一下,终于搞定了,一键把文件夹下所有的word文本全部转为繁体 |
|