|
Excel里可以这样写,供参考。- Sub 文档开始处插入文件名()
- Dim wdPath$, wdName$, iDoc As Document
- With Application.FileDialog(msoFileDialogFolderPicker)
- .Title = "请选择一个文件夹"
- If .Show = -1 Then wdPath = .SelectedItems(1) Else Exit Sub
- End With
- wdPath = wdPath & IIf(Right(wdPath, 1) = "", "", "")
- wdName = Dir(wdPath & "*.doc*")
- While wdName <> ""
- n = n + 1
- Set iDoc = Documents.Open(wdPath & wdName)
- iDoc.Range(0).Select
- Selection.InsertBefore Split(wdName, ".")(0)
- iDoc.Close True
- wdName = Dir
- Wend
- Shell "Explorer.exe " & wdPath
- MsgBox "程序执行完毕, 共处理了" & n & "个文档。"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|