Automating the application of a template to multiple files


i have ~200 documents apply word 2007 template to. instead of importing styles, etc each document, there elegant/automated way accomplish this? perhaps via the command line or batch file?
thanks, steve

had other day folder full of documents

dim fd filedialog
dim strfolder string
dim strfile string
dim doc document
'display dialog in user can select folder file saved
set fd = application.filedialog(msofiledialogfolderpicker)
fd
   .title = "select folder contains documents."
   if .show = -1 then
       'the use pressed ok, load variable strfolder path folder selected user , append path separator
       strfolder = .selecteditems(1) & "\"
   else
      'the user pressed cancel
      exit sub
   end if
end with
'close open documents before beginning
'get new title used each document
strfile = dir(strfolder & "*.doc")
while strfile <> ""
   'open document
   set doc = documents.open(strfolder & strfile)
   doc
       .updatestylesonopen = true
       .attachedtemplate = "drive:\path\templatename"
       .close wdsavechanges
   end with
   'next file in folder
   strfile = dir()
wend
 -- hope helps.

doug robbins - word mvp,
dkr[atsymbol]mvps[dot]org
posted via community bridge

"dadofour" wrote in message news:17bd81e7-8dc1-4224-94ce-7c0b45f8fdfc@communitybridge.codeplex.com...

i have ~200 documents apply word 2007 template to. instead of importing styles, etc each document, there elegant/automated way accomplish this? perhaps via command line or batch file?


thanks, steve


doug robbins - word mvp dkr[atsymbol]mvps[dot]org


Microsoft Office  >  Word IT Pro Discussions



Comments

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

Disconnecting from a Windows Server 2012 R2 file sharing session on a Windows 7,8,10 machine

Windows 2016 RDS event 1306 Connection Broker Client failed to redirect the user... Error: NULL