|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
* 楼主,下面的 3 个宏,执行 1 次,打印 1 套;执行 2 次,打印 2 套(选定文件夹及子文件夹中所有 Word 文档):
- Sub LoopFolder_xiaohualu_copy()
- Dim d, n&, m&, x&, mydir, dk, doc As Document, i&
- Set d = CreateObject("Scripting.Dictionary")
- d(SelectFolder) = ""
- Do While n < d.Count
- dk = d.keys
- mydir = Dir(dk(n), vbDirectory)
- Do While mydir <> ""
- If mydir <> "." And mydir <> ".." Then
- If GetAttr(dk(n) & mydir) = vbDirectory Then
- d(dk(n) & mydir & "") = ""
- m = m + 1
- Else
- x = x + 1
- If dk(n) & mydir Like "*.doc*" Then
- Set doc = Documents.Open(FileName:=dk(n) & mydir)
- dokcopy
- doc.Close SaveChanges:=wdSaveChanges
- i = i + 1
- End If
- End If
- End If
- mydir = Dir
- Loop
- n = n + 1
- Loop
- Set d = Nothing
- Set dk = Nothing
- MsgBox "文件夹包含 " & x & " 个文件!" & m & " 个子文件夹!" & vbCr & "共处理 Word 文档(*.docx/*.doc) " & i & " 个!", 0 + 48
- End Sub
- Sub dokcopy()
- ActiveDocument.PrintOut
- End Sub
- Function SelectFolderCopy() As String
- With Application.FileDialog(msoFileDialogFolderPicker)
- If .Show Then SelectFolderCopy = .SelectedItems(1) & "" Else End
- End With
- If MsgBox("是否处理文件夹 " & """" & SelectFolderCopy & """" & " ?", 4 + 16) = vbNo Then End
- End Function
复制代码 |
评分
-
1
查看全部评分
-
|