Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-05-2012, 08:47 AM
cdfj cdfj is offline Batch create Word documents Windows 7 32bit Batch create Word documents Office 2007
Novice
Batch create Word documents
 
Join Date: Nov 2012
Posts: 6
cdfj is on a distinguished road
Default Batch create Word documents

I have a list of about 250 topics, each of which I need to create an individually named Word document for. E.g.
Topic - boil an egg


Word file name - How to boil an egg.docx
Does anyone know of a way to do this? I thought of using the merge functionality, which would allow me to insert the topic name in <Title> in the template, but the merge functionality does not allow me to specify the file name.

Thanks!

P.S. This is not a batch conversion task!
Reply With Quote
  #2  
Old 11-05-2012, 02:11 PM
macropod's Avatar
macropod macropod is offline Batch create Word documents Windows 7 64bit Batch create Word documents Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi cdfj,

This could be done with a macro, but you'll need to provide more details about how the list is stored and where the files are to be created (eg the same folder as the list is in). Also, it's a whole lot easier if the list names are the same as the filenames or, at most, the only difference is the 'How to' expression.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 11-06-2012, 03:47 PM
cdfj cdfj is offline Batch create Word documents Windows 7 32bit Batch create Word documents Office 2007
Novice
Batch create Word documents
 
Join Date: Nov 2012
Posts: 6
cdfj is on a distinguished road
Default

Thanks, Paul,

It struck me today that I'd written a bad example. Clearly it is easiest to have a 100% match between the topic name in the list (in Excel) and the file name - so that the file name is <topic name>.docx

The topic list and the created files can be in the same directory X:\...\anywhere\

The tricky thing seems to me to link in a .dot template.

I've never written a Word macro, so if you can help me here, I will be very grateful!
Reply With Quote
  #4  
Old 11-06-2012, 04:03 PM
macropod's Avatar
macropod macropod is offline Batch create Word documents Windows 7 64bit Batch create Word documents Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by cdfj View Post
The tricky thing seems to me to link in a .dot template.
Do you have a particular template, other than Word's 'Normal' template, in mind?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 11-06-2012, 04:07 PM
cdfj cdfj is offline Batch create Word documents Windows 7 32bit Batch create Word documents Office 2007
Novice
Batch create Word documents
 
Join Date: Nov 2012
Posts: 6
cdfj is on a distinguished road
Default

Yes, one that's been made - just a Word document at present, but it can be saved as a .dot. It can have any name, as required. It's not my template, so can admit it's very clunky.
Reply With Quote
  #6  
Old 11-06-2012, 05:38 PM
macropod's Avatar
macropod macropod is offline Batch create Word documents Windows 7 64bit Batch create Word documents Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try the following Excel macro. You'll need to set the source document's filename correctly in the first 'Set wdDoc' line.

As coded, the macro looks for a docx document and saves the output files in that format. If your source document is a 'doc', not 'docx', change that part of the first 'Set wdDoc' line also. And, if you want to save in the 'doc' format, change 'wdFormatXMLDocument' to 'wdFormatDocument'.
Code:
Sub Demo()
'Note: A Reference to the Word Object Model is required.
Application.ScreenUpdating = False
Dim i As Long
Dim wdApp As Word.Application
Set wdApp = Word.Application
wdApp.Visible = False
Dim wdDoc As Word.Document
'Open the source document
Set wdDoc = wdApp.Documents.Open(Filename:="C:\Users\" & Environ("UserName") & "\Documents\MyFile.docx", _
  AddToRecentFiles:=False, Visible:=False)
With ActiveSheet
  For i = 2 To .Cells.SpecialCells(xlCellTypeLastCell).Row
    Application.StatusBar = "Creating document " & i
    'Save a copy of the document with the new filename
    wdDoc.SaveAs2 Filename:=.Cells(i, 1).Value, FileFormat:=wdFormatXMLDocument, AddToRecentFiles:=False
 Next
End With
'Close the document
wdDoc.Close SaveChanges:=False
'Close Word
wdApp.Quit
Set wdDoc = Nothing: Set wdApp = Nothing
Application.StatusBar = "Done!!"
Application.ScreenUpdating = True
End Sub
The *complete* filenames ( i.e 'How to boil an egg', not just 'boil an egg') are assumed to be in column A
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 11-07-2012, 01:03 PM
cdfj cdfj is offline Batch create Word documents Windows 7 32bit Batch create Word documents Office 2007
Novice
Batch create Word documents
 
Join Date: Nov 2012
Posts: 6
cdfj is on a distinguished road
Default

That's brilliant and very generous - thank you very much!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Batch create Word documents Dynamically create documents MrRikkie Word VBA 1 10-12-2012 09:15 AM
Batch create Word documents Linking Documents via Hyperlinks to create a "packet" moose288 Word 3 09-22-2012 08:22 PM
Batch create Word documents Batch Edit Links tosti PowerPoint 5 01-31-2012 12:51 PM
Batch create Word documents Batch run "inspect documents" ghumdinger Word VBA 3 07-21-2011 04:53 PM
Word 2007...Batch Conversion Wizard ??? mw4man Word 0 12-18-2008 04:38 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:11 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft