Making one page selections 
Author Message
 Making one page selections

This what I need to do

dim x as integer // x represents the page # so the
procedure would run on all the pages
x=1

do{

Select page (x)
{
procedure(I have the procedure)
x++

Quote:
}

While(not the end of document)

Quote:
}

this will run the procedure one page at a time from page 1
til the the end of the document.
How do I code it ??

Thanks



Wed, 13 Oct 2004 00:04:15 GMT  
 Making one page selections
Hi Mo,

You would need to tell us more about what you want to do for us to give you
the most appropriate answer.  The following code, which saves each page of a
document as a separate file, may give you some clues however:

' splitter Macro

' Macro created 16-08-98 by Doug Robbins to save each page of a document

' as a separate file with the name Page#.DOC

'

Selection.HomeKey Unit:=wdStory

Pages = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)

Counter = 0

While Counter < Pages

    Counter = Counter + 1

    DocName = "Page" & Format(Counter)

    ActiveDocument.Bookmarks("\Page").Range.Cut

    Documents.Add

    Selection.Paste

    ActiveDocument.SaveAs FileName:=DocName, FileFormat:= _

        wdFormatDocument, LockComments:=False, Password:="",
AddToRecentFiles:= _

        True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _

        False, SaveNativePictureFormat:=False, SaveFormsData:=False, _

        SaveAsAOCELetter:=False

    ActiveWindow.Close

Wend

Please post any response to the newsgroups for the benefit of others who may
also be following the thread.

Hope this helps,
Doug Robbins - Word MVP

Quote:
> This what I need to do

> dim x as integer // x represents the page # so the
> procedure would run on all the pages
> x=1

> do{

> Select page (x)
> {
> procedure(I have the procedure)
> x++
> }

> While(not the end of document)

> }
> this will run the procedure one page at a time from page 1
> til the the end of the document.
> How do I code it ??

> Thanks



Wed, 13 Oct 2004 17:41:18 GMT  
 Making one page selections
Here is the code for my template

Sub SCRIPTFORMAT()
'
' SCRIPTFORMAT Macro
' Macro recorded 04/27/99 by DMB&B
'
    Selection.WholeStory
    With ActiveDocument.PageSetup
        With .LineNumbering
            .Active = True
            .StartingNumber = 1
            .CountBy = 1
            .RestartMode = wdRestartPage
            .DistanceFromText = InchesToPoints(0.5)
        End With
        .Orientation = wdOrientPortrait
        .TopMargin = InchesToPoints(1)
        .BottomMargin = InchesToPoints(0.5)
        .LeftMargin = InchesToPoints(1.7)
        .RightMargin = InchesToPoints(1)
        .Gutter = InchesToPoints(0)
        .HeaderDistance = InchesToPoints(0.3)
        .FooterDistance = InchesToPoints(0.3)
        .PageWidth = InchesToPoints(8.5)
        .PageHeight = InchesToPoints(11)
        .FirstPageTray = wdPrinterDefaultBin
        .OtherPagesTray = wdPrinterDefaultBin
        .SectionStart = wdSectionNewPage
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = False
        .VerticalAlignment = wdAlignVerticalTop
        .SuppressEndnotes = False
        .MirrorMargins = False
    End With
    With Selection.Font
        .Name = "Courier New"
        .Size = 12
        .Bold = False
        .Italic = False
        .Underline = wdUnderlineNone
        .StrikeThrough = False
        .DoubleStrikeThrough = False
        .Outline = False
        .Emboss = False
        .Shadow = False
        .Hidden = False
        .SmallCaps = False
        .AllCaps = False
        .ColorIndex = wdAuto
        .Engrave = False
        .Superscript = False
        .Subscript = False
        .Spacing = 0
        .Scaling = 100
        .Position = 0
        .Kerning = 0
        .Animation = wdAnimationNone
    End With
    With Selection.ParagraphFormat
        .LeftIndent = InchesToPoints(0)
        .RightIndent = InchesToPoints(2.5)
        .SpaceBefore = 0
        .SpaceAfter = 0
        .LineSpacingRule = wdLineSpaceExactly
        .LineSpacing = 24.5
        .Alignment = wdAlignParagraphLeft
        .WidowControl = False
        .KeepWithNext = False
        .KeepTogether = False
        .PageBreakBefore = False
        .NoLineNumber = False
        .Hyphenation = True
        .FirstLineIndent = InchesToPoints(0)
        .OutlineLevel = wdOutlineLevelBodyText
    End With
    Selection.ParagraphFormat.TabStops.ClearAll
    ActiveDocument.DefaultTabStop = InchesToPoints(0.5)
    Selection.ParagraphFormat.TabStops.Add
Position:=InchesToPoints(1.5), _
        Alignment:=wdAlignTabLeft,
Leader:=wdTabLeaderSpaces
End Sub
Sub AUTOSUMMARIZE()
'
' AUTOSUMMARIZE Macro
' Macro created 04/27/99 by DMB&B
'
ActiveDocument.AUTOSUMMARIZE Length:=30,
Mode:=wdSummaryModeHighlight, _
    UpdateProperties:=True
End Sub
Sub sectionbreak()
'
' sectionbreak Macro
' Macro recorded 05/28/99 by DMB&B
'
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.InsertBreak Type:=wdSectionBreakNextPage
End Sub
Sub time()
'
' time Macro
' Macro recorded 05/28/99 by DMB&B
'
    Selection.TypeText Text:=" . . . DAY."
End Sub
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 05/28/99 by DMB&B
'
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Selection.TypeText Text:=" "
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Selection.TypeText Text:=" "
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Selection.TypeText Text:=" "
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Selection.TypeText Text:=" "
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Selection.TypeText Text:=" "
End Sub
//////////////////////////////////////////////
This template would number scripts, sets them to a certain
font etc... The template works with word 97, however it
doesn't work with word 2000. We use this template to make
our scripts in a standard formats. Our scripts range from
60-180 pages. When I ran the template in word 2000 with
the same script that is 20 pages long it worked. For some
reason the template wont work in 2000 with big scripts but
it would work in word 97. I think the problem is that the
script is too long for word 2000, giving me errors when I
run the Template. Is there a way I could change this
tempalte to work in 2000?

Thanks

Quote:
>-----Original Message-----
>Hi Mo,

>You would need to tell us more about what you want to do
for us to give you
>the most appropriate answer.  The following code, which

saves each page of a
Quote:
>document as a separate file, may give you some clues
however:

>' splitter Macro

>' Macro created 16-08-98 by Doug Robbins to save each
page of a document

>' as a separate file with the name Page#.DOC

>'

>Selection.HomeKey Unit:=wdStory

>Pages = ActiveDocument.BuiltInDocumentProperties
(wdPropertyPages)

>Counter = 0

>While Counter < Pages

>    Counter = Counter + 1

>    DocName = "Page" & Format(Counter)

>    ActiveDocument.Bookmarks("\Page").Range.Cut

>    Documents.Add

>    Selection.Paste

>    ActiveDocument.SaveAs FileName:=DocName, FileFormat:=
_

>        wdFormatDocument, LockComments:=False,
Password:="",
>AddToRecentFiles:= _

>        True, WritePassword:="",

ReadOnlyRecommended:=False,
Quote:
>EmbedTrueTypeFonts:= _

>        False, SaveNativePictureFormat:=False,

SaveFormsData:=False, _
Quote:

>        SaveAsAOCELetter:=False

>    ActiveWindow.Close

>Wend

>Please post any response to the newsgroups for the

benefit of others who may

- Show quoted text -

Quote:
>also be following the thread.

>Hope this helps,
>Doug Robbins - Word MVP


>> This what I need to do

>> dim x as integer // x represents the page # so the
>> procedure would run on all the pages
>> x=1

>> do{

>> Select page (x)
>> {
>> procedure(I have the procedure)
>> x++
>> }

>> While(not the end of document)

>> }
>> this will run the procedure one page at a time from
page 1
>> til the the end of the document.
>> How do I code it ??

>> Thanks

>.



Sun, 17 Oct 2004 03:31:50 GMT  
 Making one page selections
Hi Mo,

When you say it doesn't work, does it cause an error?  If so, what line in
the macro is highlighted if you click on the debug button of the error
dialog that appears, and what message is being displayed in that dialog?

Please post any response to the newsgroups for the benefit of others who may
also be following the thread.

Hope this helps,
Doug Robbins - Word MVP

Quote:
> Here is the code for my template

> Sub SCRIPTFORMAT()
> '
> ' SCRIPTFORMAT Macro
> ' Macro recorded 04/27/99 by DMB&B
> '
>     Selection.WholeStory
>     With ActiveDocument.PageSetup
>         With .LineNumbering
>             .Active = True
>             .StartingNumber = 1
>             .CountBy = 1
>             .RestartMode = wdRestartPage
>             .DistanceFromText = InchesToPoints(0.5)
>         End With
>         .Orientation = wdOrientPortrait
>         .TopMargin = InchesToPoints(1)
>         .BottomMargin = InchesToPoints(0.5)
>         .LeftMargin = InchesToPoints(1.7)
>         .RightMargin = InchesToPoints(1)
>         .Gutter = InchesToPoints(0)
>         .HeaderDistance = InchesToPoints(0.3)
>         .FooterDistance = InchesToPoints(0.3)
>         .PageWidth = InchesToPoints(8.5)
>         .PageHeight = InchesToPoints(11)
>         .FirstPageTray = wdPrinterDefaultBin
>         .OtherPagesTray = wdPrinterDefaultBin
>         .SectionStart = wdSectionNewPage
>         .OddAndEvenPagesHeaderFooter = False
>         .DifferentFirstPageHeaderFooter = False
>         .VerticalAlignment = wdAlignVerticalTop
>         .SuppressEndnotes = False
>         .MirrorMargins = False
>     End With
>     With Selection.Font
>         .Name = "Courier New"
>         .Size = 12
>         .Bold = False
>         .Italic = False
>         .Underline = wdUnderlineNone
>         .StrikeThrough = False
>         .DoubleStrikeThrough = False
>         .Outline = False
>         .Emboss = False
>         .Shadow = False
>         .Hidden = False
>         .SmallCaps = False
>         .AllCaps = False
>         .ColorIndex = wdAuto
>         .Engrave = False
>         .Superscript = False
>         .Subscript = False
>         .Spacing = 0
>         .Scaling = 100
>         .Position = 0
>         .Kerning = 0
>         .Animation = wdAnimationNone
>     End With
>     With Selection.ParagraphFormat
>         .LeftIndent = InchesToPoints(0)
>         .RightIndent = InchesToPoints(2.5)
>         .SpaceBefore = 0
>         .SpaceAfter = 0
>         .LineSpacingRule = wdLineSpaceExactly
>         .LineSpacing = 24.5
>         .Alignment = wdAlignParagraphLeft
>         .WidowControl = False
>         .KeepWithNext = False
>         .KeepTogether = False
>         .PageBreakBefore = False
>         .NoLineNumber = False
>         .Hyphenation = True
>         .FirstLineIndent = InchesToPoints(0)
>         .OutlineLevel = wdOutlineLevelBodyText
>     End With
>     Selection.ParagraphFormat.TabStops.ClearAll
>     ActiveDocument.DefaultTabStop = InchesToPoints(0.5)
>     Selection.ParagraphFormat.TabStops.Add
> Position:=InchesToPoints(1.5), _
>         Alignment:=wdAlignTabLeft,
> Leader:=wdTabLeaderSpaces
> End Sub
> Sub AUTOSUMMARIZE()
> '
> ' AUTOSUMMARIZE Macro
> ' Macro created 04/27/99 by DMB&B
> '
> ActiveDocument.AUTOSUMMARIZE Length:=30,
> Mode:=wdSummaryModeHighlight, _
>     UpdateProperties:=True
> End Sub
> Sub sectionbreak()
> '
> ' sectionbreak Macro
> ' Macro recorded 05/28/99 by DMB&B
> '
>     Selection.Delete Unit:=wdCharacter, Count:=1
>     Selection.InsertBreak Type:=wdSectionBreakNextPage
> End Sub
> Sub time()
> '
> ' time Macro
> ' Macro recorded 05/28/99 by DMB&B
> '
>     Selection.TypeText Text:=" . . . DAY."
> End Sub
> Sub Macro1()
> '
> ' Macro1 Macro
> ' Macro recorded 05/28/99 by DMB&B
> '
>     Selection.MoveRight Unit:=wdCharacter, Count:=1
>     Selection.TypeText Text:=" "
>     Selection.MoveRight Unit:=wdCharacter, Count:=1
>     Selection.TypeText Text:=" "
>     Selection.MoveRight Unit:=wdCharacter, Count:=1
>     Selection.TypeText Text:=" "
>     Selection.MoveRight Unit:=wdCharacter, Count:=1
>     Selection.TypeText Text:=" "
>     Selection.MoveRight Unit:=wdCharacter, Count:=1
>     Selection.TypeText Text:=" "
> End Sub
> //////////////////////////////////////////////
> This template would number scripts, sets them to a certain
> font etc... The template works with word 97, however it
> doesn't work with word 2000. We use this template to make
> our scripts in a standard formats. Our scripts range from
> 60-180 pages. When I ran the template in word 2000 with
> the same script that is 20 pages long it worked. For some
> reason the template wont work in 2000 with big scripts but
> it would work in word 97. I think the problem is that the
> script is too long for word 2000, giving me errors when I
> run the Template. Is there a way I could change this
> tempalte to work in 2000?

> Thanks

> >-----Original Message-----
> >Hi Mo,

> >You would need to tell us more about what you want to do
> for us to give you
> >the most appropriate answer.  The following code, which
> saves each page of a
> >document as a separate file, may give you some clues
> however:

> >' splitter Macro

> >' Macro created 16-08-98 by Doug Robbins to save each
> page of a document

> >' as a separate file with the name Page#.DOC

> >'

> >Selection.HomeKey Unit:=wdStory

> >Pages = ActiveDocument.BuiltInDocumentProperties
> (wdPropertyPages)

> >Counter = 0

> >While Counter < Pages

> >    Counter = Counter + 1

> >    DocName = "Page" & Format(Counter)

> >    ActiveDocument.Bookmarks("\Page").Range.Cut

> >    Documents.Add

> >    Selection.Paste

> >    ActiveDocument.SaveAs FileName:=DocName, FileFormat:=
> _

> >        wdFormatDocument, LockComments:=False,
> Password:="",
> >AddToRecentFiles:= _

> >        True, WritePassword:="",
> ReadOnlyRecommended:=False,
> >EmbedTrueTypeFonts:= _

> >        False, SaveNativePictureFormat:=False,
> SaveFormsData:=False, _

> >        SaveAsAOCELetter:=False

> >    ActiveWindow.Close

> >Wend

> >Please post any response to the newsgroups for the
> benefit of others who may
> >also be following the thread.

> >Hope this helps,
> >Doug Robbins - Word MVP


> >> This what I need to do

> >> dim x as integer // x represents the page # so the
> >> procedure would run on all the pages
> >> x=1

> >> do{

> >> Select page (x)
> >> {
> >> procedure(I have the procedure)
> >> x++
> >> }

> >> While(not the end of document)

> >> }
> >> this will run the procedure one page at a time from
> page 1
> >> til the the end of the document.
> >> How do I code it ??

> >> Thanks

> >.



Sun, 17 Oct 2004 04:54:31 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. One record on one page...

2. Post data from one page to another (BOA page) vb.net

3. How To - Pass the content of a variable on one page to another page

4. Run-time error when making selection in Word from Access

5. Getting related fields when a selection is made thru DBCombo

6. Process selected items in Listview before new selections made

7. Need to Initiate Action Immediately When Combo Box Selection Made

8. Combo Listbox not disappearing after selection made.

9. MSFlexGrid: Has a selection been made???

10. Getting related fields when a selection is made thru DBCombo

11. Problem making a DataGrid Selection permanent: how to ?

12. Moving selections from one listbox to another

 

 
Powered by phpBB® Forum Software