2014-07-01 55 views

回答

0

最簡單的方法是使用Word VBA。

將200個將被分配樣式的Word文件放到一個不包含其他文件的目錄中。然後在其他位置創建一個.dotm(Word 2007或更高版本)或.dot(Word 2003或更低版本)模板文件。創建樣式模板文件被複制,並把下面的代碼放到同一個模板文件中的模塊(ALT-F11鍵可編輯):

Sub BatchCopyStyles() 

'Make sure that the template that contains the style to be copied and this code 
'is open and acting as the active document before running this macro 

Dim file As Variant 
Dim folderPath As String 'path to files receiving the style 
Dim targetPath As String 
Dim templateFile As String 'file that contains style and this code 
Dim styleTemplate As Document 

folderPath = "C:\Users\Joe\Desktop\TargetFolder\" 
templateFile = "C:\Users\Joe\Desktop\CopyStyle.dotm" 

Set styleTemplate = ActiveDocument 
file = Dir(folderPath) 

    While (file <> "") 
     Set file = Documents.Open(FileName:=folderPath & file) 
     styleTemplate.Activate 
     targetPath = folderPath & file 
     Application.OrganizerCopy Source:=templateFile, _ 
        Destination:=targetPath, _ 
        Name:="StyleToCopy", _ 
        Object:=wdOrganizerObjectStyles 
     file.Close wdSaveChanges 
     file = Dir 
    Wend 
End Sub 

編輯爲正確的路徑代碼,文件名稱,樣式名稱等。使用包含此代碼的文件和要指定爲活動文檔的樣式,從VBA編輯器(F5)運行宏。這將打開每個文件,複製樣式,然後關閉文件。打開和關閉文檔200次不會很好,但它應該完成這項工作。

相關問題