![]() |
|
#1
|
|||
|
|||
|
I found a macro on word.tips.net for doing a mass formatting on all files in a folder of your choice.
It was worked great for about 3 times, now getting an error showing: "Run-time error '5174': This file could not be found. Then when Debug, it highlights Application.Documents.Open FileName:=JName Code:
Sub MassFormatFiles()
'
' MassFormatFiles Macro
' Page Setup dialog box. Thus, things like paper size, margins, header and footer locations, and orientation
'
Dim JName As String
Dialogs(wdDialogFileOpen).Show
Application.ScreenUpdating = False
JName = Dir("*.doc")
While (JName > "")
Application.Documents.Open FileName:=JName
'Do formatting here
With Selection.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(0.5)
.BottomMargin = InchesToPoints(0.5)
.LeftMargin = InchesToPoints(0.5)
.RightMargin = InchesToPoints(0.5)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.5)
.FooterDistance = InchesToPoints(0.5)
.PageWidth = InchesToPoints(8.5)
.PageHeight = InchesToPoints(11)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.BookFoldPrinting = False
.BookFoldRevPrinting = False
.BookFoldPrintingSheets = 1
.GutterPos = wdGutterPosLeft
End With
Selection.WholeStory
Selection.Font.Name = "Times New Roman"
Selection.Font.Size = 12
Selection.HomeKey Unit:=wdStory
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Style = ActiveDocument.Styles("Heading 1")
Selection.Font.Name = "Times New Roman"
Selection.Font.Size = 22
Selection.Font.Color = 192
ActiveDocument.Close SaveChanges:=wdSaveChanges
JName = Dir()
Wend
Application.ScreenUpdating = True
End Sub
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Need macro to merge files in Word and preserve formatting
|
Carolin | Word VBA | 3 | 12-14-2014 04:01 AM |
| Oulook Mass Mailing | mak39 | Outlook | 1 | 12-23-2013 10:15 AM |
Mass replacing word(s)
|
alysolyman | Word VBA | 10 | 02-27-2013 01:56 PM |
Mass e-mail seperation
|
daryl | Mail Merge | 1 | 03-23-2010 03:45 PM |
Mass attachment downloads?
|
dpool2002 | Outlook | 1 | 06-21-2006 02:11 PM |