1 つのファイルにマージ (結合) する必要がある Word ファイルが多数あり、Word マージを (1 つずつ) 使用するには時間がかかります。この仕事を処理できるツールを経験したことがありますか?
5586 次
3 に答える
4
Sub MergeAllDocuments(AllDocumentsPath as String, MasterDocumentPath as String)
Dim MasterDocument As Document
Set MasterDocument = Documents.Open(FileName:=MasterDocumentPath)
TheDocumentPath = Dir(AllDocumentsPath , vbNormal)
While TheDocumentPath <> ""
' Append the next doc to the end of the master doc. (The
' special "\EndOfDoc" bookmark is always available!)
MasterDocument.Bookmarks("\EndOfDoc").Range.InsertFile TheDocumentPath
TheDocumentPath = Dir
Wend
MasterDocument.Save
End Sub
MergeAllDocuments "C:\MySeparateDocuments\*.doc", "C:\MasterDocument.doc"
1 つ質問があります。なぜそのようなことをしたいのですか (少なくとも「膨大な数」のドキュメントで)。
于 2008-11-10T09:55:54.153 に答える
2
しばらく前に Graham Skan の投稿に出くわしました。それはあなたを始めるかもしれません:
Sub InsertFiles()
Dim strFileName As String
Dim rng As Range
Dim Doc As Document
Const strPath = "C:\Documents and Settings\Graham Skan\My Documents\Allwork\" 'adjust as necessary '"
Set Doc = Documents.Add
strFileName = Dir$(strPath & "\*.doc")
Do
Set rng = Doc.Bookmarks("\EndOfDoc").Range
If rng.End > 0 Then 'section break not necessary before first document.'
rng.InsertBreak wdSectionBreakNextPage
rng.Collapse wdCollapseEnd
End If
rng.InsertFile strPath & "\" & strFileName
strFileName = Dir$()
Loop Until strFileName = ""
End Sub
于 2008-11-10T09:46:57.290 に答える
0
Word COM API を使用してみましたか? 多くのことを自動化できます。マージを自動化できるかもしれません。
実際にマージする必要がありますか、それともファイルを結合したいですか。2つのことはまったく異なります。
マージは、(潜在的に競合する) 変更を含む元のファイルの 2 つのバージョンがある場合に使用されます。すべてをマージするために必要な「膨大な数」のファイルがどのように存在するのか、私にはよくわかりません。これは紛争の絶対的な悪夢となるでしょう。それらのセットを個々のファイルにマージするつもりですか?
結合は、それらを次々に連結したい場合です。これははるかに簡単です。これは、COM API を使用することで可能になります。
于 2008-11-10T09:39:24.110 に答える