Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-28-2015, 04:12 PM
WH7262 WH7262 is offline Mass Formatting of Files Windows Vista Mass Formatting of Files Office 2007
Novice
Mass Formatting of Files
 
Join Date: Aug 2014
Location: Texas
Posts: 7
WH7262 is on a distinguished road
Default Mass Formatting of Files

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
I have tried this several times, still failing. Any suggestions would be greater appreciated.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mass Formatting of Files 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 Formatting of Files Mass replacing word(s) alysolyman Word VBA 10 02-27-2013 01:56 PM
Mass Formatting of Files Mass e-mail seperation daryl Mail Merge 1 03-23-2010 03:45 PM
Mass Formatting of Files Mass attachment downloads? dpool2002 Outlook 1 06-21-2006 02:11 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:05 PM.


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