我需要2个宏来帮助我更快地完成工作:
实施例。
"R O M Â N I A
ÎNALTA CURTE DE CASAŢIE ŞI JUSTIŢIE
SECŢIA CIVILĂ ŞI DE PROPRIETATE INTELECTUALĂ **(this is aligned at left or centered, and always has 2 enters after it for inserting the table, only this line may be different but the first to are always the same)**
Decizia nr. **2570** Dosar nr. **9304/1/2009**
Şedinţa publică ..."
所有文件都以此文字开头,只有与asterix不同的文件“
我必须使用“Decizie”,“Dosar”和数字为该行创建一个表格 像这样的东西:
"R O M Â N I A
ÎNALTA CURTE DE CASAŢIE ŞI JUSTIŢIE
SECŢIA CIVILĂ ŞI DE PROPRIETATE INTELECTUALĂ
|Decizia nr. *2570/**2009*** | Dosar nr. *9304/1/2009*| - a table without borders, first column aligned left, second one right, at the first column also added the date from the second one
Şedinţa publică ..."
有人可以帮助我自动创建此表的宏吗?
答案 0 :(得分:0)
通过组合以及表格中究竟应该是什么来表达你的意思并不是很清楚。如果你想在一个“组合”的doc文件中包含许多文档的内容,那么这里是第二个宏的快速而肮脏的解决方案:
请注意,在VBA编辑器的工具/参考中,您必须在可用库下检查“Microsoft Scripting Runtime”。
Dim fs As New FileSystemObject
Dim fo As Folder
Dim fi As File
Sub processDocFiles()
Dim doc As Document
Dim thisdoc As Document
Set thisdoc = ActiveDocument
' set the directory
Set fo = fs.GetFolder("C:\Temp\doc")
' iterate through the files
For Each fi In fo.Files
' check the files
If (fi.Name <> ActiveDocument.Name) And (Left(fi.Name, 1) <> "~") And (Right(fi.Name, 5) = ".docx") Then
Debug.Print "Processing " & fi.Name
Set doc = Application.Documents.Open(fi.Path)
' doc.Content.InsertAfter (fi.Path)
thisdoc.Content.InsertAfter (doc.Content)
thisdoc.Content.InsertAfter ("--------------------------------------------------" & Chr(13) & Chr(10))
doc.Close
End If
Next
End Sub
这会将文件夹中所有doc文件的内容复制到一个文档中。 另一个是:
Sub delImages()
Dim doc As Document
Dim thisdoc As Document
Set thisdoc = ActiveDocument
' set the directory
Set fo = fs.GetFolder("C:\Temp\doc")
' iterate through the files
For Each fi In fo.Files
' check the files
If (fi.Name <> ActiveDocument.Name) And (Left(fi.Name, 1) <> "~") And (Right(fi.Name, 5) = ".docx") Then
Debug.Print "Processing " & fi.Name
Set doc = Application.Documents.Open(fi.Path)
For Each pic In doc.InlineShapes
pic.Delete
Next
doc.Save
doc.Close
End If
Next
End Sub