Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Word 2003 Selection or Range Objects
I have a large document of 270 pages. I need to save each page as a separate
rtf file. I tried recording a macro and modifying it to iterate through all the pages selecting, copying and saving as a new document, but the selection starting from the beginning of the page using shift & ctrl-pgdn-pgdn would not select the page when used in the macro (it did fine when using it from the keyboard). I do not understand how to make the selection in VBA using the range or selection objects. Any help in how to set the selection for a page would be much appreciated -- Thanks much Lako |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Word 2003 Selection or Range Objects
Hi Lako,
Use this macro: Sub MakeDocs() Const strSaveDir As String = "G:\temp" Dim intN As Integer, strN As String For intN = 1 To ActiveDocument.BuiltInDocumentProperties(wdPropert yPages) strN = LTrim(Str(intN)) Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:=strN ActiveDocument.Bookmarks("\Page").Select Selection.Copy Documents.Add Selection.Paste ActiveDocument.SaveAs FileName:=strSaveDir & "\RTFDoc" & strN & ".rtf", _ FileFormat:=wdFormatRTF, AddToRecentFiles:=False ActiveDocument.Close Next intN End Sub Substitute "G:\temp" for the directory in which yout rtf documents are to be saved. Be sure your 270 page document is the active document when you run the macro. The macro creates filenames like "RTFDoc1.rtf", "RTFDoc2.rtf" and so on. The files are based on Normal dot. If you set the default margins slightly wider or the default font size somewhat smaller, you prevent creating a blank second page. Good luck, Cooz -- PS: If this is a satisfying answer to your question and you're logged in via the Microsoft site, please click Yes to "Did this post answer the question?". Thanks. "Lako" wrote: I have a large document of 270 pages. I need to save each page as a separate rtf file. I tried recording a macro and modifying it to iterate through all the pages selecting, copying and saving as a new document, but the selection starting from the beginning of the page using shift & ctrl-pgdn-pgdn would not select the page when used in the macro (it did fine when using it from the keyboard). I do not understand how to make the selection in VBA using the range or selection objects. Any help in how to set the selection for a page would be much appreciated -- Thanks much Lako |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Word 2003 Selection or Range Objects
Cooz
I am up and running. -- Thanks for the help. Lako "Cooz" wrote: Hi Lako, Use this macro: Sub MakeDocs() Const strSaveDir As String = "G:\temp" Dim intN As Integer, strN As String For intN = 1 To ActiveDocument.BuiltInDocumentProperties(wdPropert yPages) strN = LTrim(Str(intN)) Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:=strN ActiveDocument.Bookmarks("\Page").Select Selection.Copy Documents.Add Selection.Paste ActiveDocument.SaveAs FileName:=strSaveDir & "\RTFDoc" & strN & ".rtf", _ FileFormat:=wdFormatRTF, AddToRecentFiles:=False ActiveDocument.Close Next intN End Sub Substitute "G:\temp" for the directory in which yout rtf documents are to be saved. Be sure your 270 page document is the active document when you run the macro. The macro creates filenames like "RTFDoc1.rtf", "RTFDoc2.rtf" and so on. The files are based on Normal dot. If you set the default margins slightly wider or the default font size somewhat smaller, you prevent creating a blank second page. Good luck, Cooz -- PS: If this is a satisfying answer to your question and you're logged in via the Microsoft site, please click Yes to "Did this post answer the question?". Thanks. "Lako" wrote: I have a large document of 270 pages. I need to save each page as a separate rtf file. I tried recording a macro and modifying it to iterate through all the pages selecting, copying and saving as a new document, but the selection starting from the beginning of the page using shift & ctrl-pgdn-pgdn would not select the page when used in the macro (it did fine when using it from the keyboard). I do not understand how to make the selection in VBA using the range or selection objects. Any help in how to set the selection for a page would be much appreciated -- Thanks much Lako |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
take yet another lesson from wordperfect "reveal codes" | Microsoft Word Help | |||
Word should allow to 'divide' page by 3 or 4, not just 2 | Page Layout | |||
Does Word have a QuickCorrect/Quick Word option like WordPerfect? | New Users | |||
In Word, how do I surpress headers and footers on page 2 | Microsoft Word Help | |||
Envelope Address | New Users |