Format several docs at once?

M

mrs_ruppel

At work we have to run reports, export them, save them as Word documents, and
then reformat the page orientation to legal. Is there any way to do this to
several documents at once? I HATE having to open each document individually
and reformat one-by-one...
 
G

Graham Mayor

It would certainly be possible to open a batch of folders and change the
page layout (see macro below), but it would probably be simpler to start off
with the reports in Legal format by basing the documents on a correctly
formatted template. How are the Word documents created?

Sub SaveAllAsLegal()
Dim strFileName As String
Dim strDocName() As String
Dim strPath As String
Dim oDoc As Document
Dim fDialog As FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)

With fDialog
.Title = "Select folder and click OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled By User", , "Legal Page Layout"
Exit Sub
End If
strPath = fDialog.SelectedItems.Item(1)
If Right(strPath, 1) <> "\" Then strPath = strPath + "\"
End With

If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If

strFileName = Dir$(strPath & "*.doc")

While Len(strFileName) <> 0
Set oDoc = Documents.Open(strPath & strFileName)
With oDoc.PageSetup
.PageWidth = InchesToPoints(8.5)
.PageHeight = InchesToPoints(14)
End With
oDoc.Close SaveChanges:=wdSaveChanges
strFileName = Dir$()
Wend
End Sub

http://www.gmayor.com/installing_macro.htm


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

mrs_ruppel

We run the reports out of MOBIUS and then have to convert then from *.rpt* to
*.doc*. But I have to open them individually and reformat each to come up
landscape & legal.
 
G

Graham Mayor

OK, for landscape you will need to swap the height and width in the macro
thus

With oDoc.PageSetup
.PageWidth = InchesToPoints(14)
.PageHeight = InchesToPoints(8.5)
End With

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top