0

作業をより速く完了するのに役立つ 2 つのマクロが必要です。

  • ドキュメントからすべての画像を削除する(場所に関係なく)。
  • 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ă ..." 

すべてのファイルはこのテキストで始まり、アスタリスクが付いているものだけが異なります

そして、「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ă ..."

このテーブルを自動的に作成するマクロを手伝ってくれる人はいますか?

4

1 に答える 1

0

組み合わせて何を意味するのか、正確には何をテーブルに入れるべきなのかは明確ではありません。多数のドキュメントのコンテンツを 1 つの「結合された」ドキュメント ファイルに格納したい場合は、2 番目のマクロに対する手っ取り早い解決策を次に示します。

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

これにより、フォルダー内のすべてのドキュメント ファイルの内容が 1 つのドキュメントにコピーされます。もう1つは次のとおりです。

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
于 2012-08-24T09:30:42.667 に答える