|
Answer» I NEED a batch file that will allow me to reformat all Word documents in a folder. Specifically I need to change the margins and font. Can anyone help me with this? I would very much appreciate it!CindyM, you need a program (VBS or something else) to do the change. The batch file is your last problem. And... I don't know to do that program. I know it's relatively easy to create a "macro" in Word, but I don't know to automatically apply to all the documents in a folder. In fact, I know a way, to open EVERY document and launch the macro. But automatically... I don't know. This problem is not a DOS problem (I know you want a BAT file, but not the batch file is the answer to your problem... Or at LEAST, not yet). It's an office problem, and you may ask help from programmers also.Viking is right. You could either use a VBA macro which would run inside Word or you can use a script which runs OUTSIDE of Word. The sample code is a script solution:
Code: [Select]Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFolder("c:\documents") ' change as necessary Set FC = f.Files
For Each fs In fc If fs.Type = "Microsoft Word Document" Then Set objWord = CreateObject("Word.Application") With objWord .Documents.Open """" & fs & """" .Selection.WholeStory .Selection.Font.Name = "Brush Script MT" .Selection.Font.Size = 36 .ActiveDocument.PageSetup.TopMargin = 1.5 .ActiveDocument.PageSetup.BottomMargin = 1.5 ' .Visible = True .ActiveDocument.Save End With Set objWord = Nothing End If Next
You will need to change the directory and if you want to watch the script run, remove the single quote from the visible=true line. You will probably also want to change the values for the font name, size and the margins.
After saving the script with a vbs extension you can run from the command prompt as cscript scriptname.vbs.
Hope this helps. 8-)
|