If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Format several docs at once?
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... |
#2
|
|||
|
|||
Format several docs at once?
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 My web site www.gmayor.com Word MVP web site http://word.mvps.org mrs_ruppel wrote: 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... |
#3
|
|||
|
|||
Format several docs at once?
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. "Graham Mayor" wrote: 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 My web site www.gmayor.com Word MVP web site http://word.mvps.org mrs_ruppel wrote: 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... |
#4
|
|||
|
|||
Format several docs at once?
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 My web site www.gmayor.com Word MVP web site http://word.mvps.org mrs_ruppel wrote: 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. "Graham Mayor" wrote: 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 My web site www.gmayor.com Word MVP web site http://word.mvps.org mrs_ruppel wrote: 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... |
Thread Tools | |
Display Modes | |
|
|