![]() |
|
#6
|
||||
|
||||
|
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
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Batch run "inspect documents"
|
ghumdinger | Word VBA | 4 | 05-13-2024 08:51 PM |
Dynamically create documents
|
MrRikkie | Word VBA | 1 | 10-12-2012 09:15 AM |
Linking Documents via Hyperlinks to create a "packet"
|
moose288 | Word | 3 | 09-22-2012 08:22 PM |
Batch Edit Links
|
tosti | PowerPoint | 5 | 01-31-2012 12:51 PM |
| Word 2007...Batch Conversion Wizard ??? | mw4man | Word | 0 | 12-18-2008 04:38 PM |