#1
|
|||
|
|||
How to go through subdirectories in the following macro
Hello everyone. I have the following macro to batch change the templates of all word documents in a folder. However, there are several subdirectories within that folder as well, so I would like to have it check those as well. Can anyone modify it so that it does that? Code:
Sub ChangeTemplates() Dim strDocPath As String Dim strTemplateB As String Dim strCurDoc As String Dim docCurDoc As Document ' set document folder path and template strings strDocPath = "C:\Users\servicedesk\Desktop\Test\" strTemplateB = "C:\Users\servicedesk\Desktop\Blanco.dotx" ' get first doc - only time need to provide file spec strCurDoc = Dir(strDocPath & "*.doc") ' ready to loop (for as long as file found) Do While strCurDoc <> "" ' open file Set docCurDoc = Documents.Open(FileName:=strDocPath & strCurDoc) ' change the template docCurDoc.AttachedTemplate = strTemplateB ' save and close docCurDoc.Close wdSaveChanges ' get next file name strCurDoc = Dir Loop MsgBox "Finished" End Sub |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
custom icon, undo/redo for macro, permanent macro | Rapier | Excel | 0 | 08-05-2013 06:30 AM |
How do I assign a macro to a button when the macro is in my personal workbook? | foolios | Excel Programming | 2 | 07-27-2011 02:41 PM |