Auto Duplicate a Page in Word?

A

aal

I want to create a template. The template will have two pages with a
different design for each (first page represents the front of a doc, the
second page represents the back of the doc for two-sided printing). When
necessary, I need Word to auto duplicate the page one design for odd pages
(3, 5, so on) and page two design for even pages (4, 6, so on). I'm sure
there is a code or something to do this. Maybe a macro or Visual Basic?
Please help!
 
F

fumei via OfficeKB.com

Depending on whether I understand this correctly, and what exactly you mean
by design...

Make the design for odd pages. Make the design for even pages.

Set the template to use Different Odd and Even (File > Page Setup > Layout)


Done. No code required.
 
A

aal

Well, if I create a template to use on new documents (just the same as if I
downloaded a Word 2007 template, for example), the design of page 1(logo,
text boxes, etc.) will look different than page 2. I need all odd pages to
have the same layout/text boxes/logo/design elements and all even pages to
look like page 2 layout/text boxes/design elments. I'm not sure how the
steps you mentioned would work for this other than header and footer, which
is not what I am talking about. Can you explain further?
 
G

Graham Mayor

The different odd/even page will take care of the header/footer and margins.
For the elements on the document page you could probably use a pair of
autotext/autocorrect entries to insert them.

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
T

Tony Strazzeri

Hi aal,


I think the previous advice about using different odd/even header
footers is the best from what I assume you are talking about.

Do you realise that the header/footer is not limited to having
elements at top and bottom of the page?

I have created something that may be similar, a two single page flyer
template. The fist page layout contains logos and disclaimers etc at
various positions on the page. By putting these in a text box/frame
or picture they can be placed to appera anywhere on the page. The
second page is similar but with different elements.

This allows that text to sit in the main document body area but the
text will wrap around the elements apearing from the header/footer.

The third and fourth page can then be a different flyer but follow the
same layout. Is this sort of what you are wanting to do?

Hope this helps.

Cheers
TonyS.
 
T

Tony Strazzeri

Hi aal,

I won't post the tempate for you as it is bad practice to attach
things to newsgroup posts.


Run the code below on a new blank document in Pagelayout view it
should create the layout I am talking about.
the document has two columns on the front and three on the back
page.

The header of the front contains some shapes to demonstrate what I am
referring to. As you can see the text in the main document flows
around those elements.

If too much text is put into the first page, it will continue onto
page two but you will see that the two column layout will continue as
two columns, but you can see that the second/even page header
appears. Obviously it is up to the user to reduce/restrict their
content to a single page in this situation. Ditto for the second/back/
even page.

If you need a second layout say for another flyer in the same layout
just insert a newpage section break and copy the column layout.

I hope the helps.

Cheers
TonyS.


Sub DemoTwoPageFlyerLayout()
'
' Macro1 Macro
' Macro 3/28/2008 by Tony Strazzeri
'
Dim shp As Shape
Const strSomeText = "The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog. " _
& "The quick brown fox jumps over the lazy dog. The quick
brown fox jumps over the lazy dog. " _
& "The quick brown fox jumps over the lazy dog." & vbCr _
& "The quick brown fox jumps over the lazy dog. The quick
brown fox jumps over the lazy dog. " _
& "The quick brown fox jumps over the lazy dog. The quick
brown fox jumps over the lazy dog."

With ActiveDocument.PageSetup
.Orientation = wdOrientPortrait
.OddAndEvenPagesHeaderFooter = True
.DifferentFirstPageHeaderFooter = False

With .TextColumns
.SetCount NumColumns:=2
.EvenlySpaced = True
.LineBetween = False
.Width = CentimetersToPoints(6.99)
.Spacing = CentimetersToPoints(1.27)
End With
End With


ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader

ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range.Text =
"Front page Footer." & vbTab & "See the back for more news."

Set shp =
Selection.HeaderFooter.Shapes.AddShape(msoShapeHorizontalScroll, 130,
10#, 380#, 120#)
shp.Select
With shp
.LockAnchor = False
.WrapFormat.AllowOverlap = True
.WrapFormat.Side = wdWrapBoth
End With

Selection.Collapse wdCollapseEnd
shp.TextFrame.TextRange.Text = "This is the banner"


Set shp =
Selection.HeaderFooter.Shapes.AddShape(msoShapeDoubleBracket, 18.6,
45#, 99.75, 693#) '.Select
shp.TextFrame.TextRange.Text = "This could have Addess and contact
information."

Set shp =
Selection.HeaderFooter.Shapes.AddShape(msoShapeFlowchartSequentialAccessStorage,
292.2, 324#, 262.2, 117#)
shp.TextFrame.TextRange = "News of the Week"

ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

Selection.TypeText Text:="This text appears in the document body.
The other stuff is in the header, but it could be in both header and
footer."
Selection.TypeParagraph
Selection.TypeParagraph

'Add some text
For I = 1 To 5: Selection.TypeText strSomeText: Next

Selection.TypeParagraph
Selection.TypeParagraph
Selection.InsertBreak Type:=wdSectionBreakNextPage

With Selection.PageSetup.TextColumns
.SetCount NumColumns:=3
.EvenlySpaced = True
.LineBetween = True
End With


ActiveDocument.Sections(2).Footers(wdHeaderFooterEvenPages).Range.Text
= "This is in the back/even page footer"


ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader

Set shp = Selection.HeaderFooter.Shapes.AddShape(msoShapeWave,
89.85, 45#, 459#, 45#)
shp.TextFrame.TextRange.Text = "This banner is on the Even pages"
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

For I = 1 To 5: Selection.TypeText strSomeText: Next


Selection.TypeParagraph
End Sub
 
T

Tony Strazzeri

Hi aal,

Apologies for the repost (if it appears). I posted a reply but it has
not appeared when I looked for it so heregoes (again).


The following code will create the layout I am referring to.

It contains two sections only so that I can format the first page as
two columns and the second as three. The sections are not needed to
implement the different Odd/Even pages.

The first page has several shapes in the header to simulate possible
graphic/layout elements. The second page has a different banner
across the top. These are in the headers so that the user does not
need to worry about shifting them accidentally.

The main body of the document can just have the text content.

It is up to the user to ensure that the content for each page is
limited to a single page otherwise the text will frlow onto the next
page and carry the column formatting but will of course have the
appropriate odd/even header/banner.

If you want additional sets of layout in the same document you just
need to insert a section break at the end of each page pair and adjust
the column count and headers accordingly. Hope this helps.

Cheers
TonyS.

Sub DemoTwoPageFlyerLayout()
'
' Macro1 Macro
' Macro 3/28/2008 by Tony Strazzeri
'
Dim shp As Shape
Const strSomeText = "The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog. " _
& "The quick brown fox jumps over the lazy dog. The quick
brown fox jumps over the lazy dog. " _
& "The quick brown fox jumps over the lazy dog." & vbCr _
& "The quick brown fox jumps over the lazy dog. The quick
brown fox jumps over the lazy dog. " _
& "The quick brown fox jumps over the lazy dog. The quick
brown fox jumps over the lazy dog."

With ActiveDocument.PageSetup
.Orientation = wdOrientPortrait
.OddAndEvenPagesHeaderFooter = True
.DifferentFirstPageHeaderFooter = False

With .TextColumns
.SetCount NumColumns:=2
.EvenlySpaced = True
.LineBetween = False
.Width = CentimetersToPoints(6.99)
.Spacing = CentimetersToPoints(1.27)
End With
End With


ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader

ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range.Text =
"Front page Footer." & vbTab & "See the back for more news."

Set shp =
Selection.HeaderFooter.Shapes.AddShape(msoShapeHorizontalScroll, 130,
10#, 380#, 120#)
shp.Select
With shp
.LockAnchor = False
.WrapFormat.AllowOverlap = True
.WrapFormat.Side = wdWrapBoth
End With

Selection.Collapse wdCollapseEnd
shp.TextFrame.TextRange.Text = "This is the banner"


Set shp =
Selection.HeaderFooter.Shapes.AddShape(msoShapeDoubleBracket, 18.6,
45#, 99.75, 693#) '.Select
shp.TextFrame.TextRange.Text = "This could have Addess and contact
information."

Set shp =
Selection.HeaderFooter.Shapes.AddShape(msoShapeFlowchartSequentialAccessStorage,
292.2, 324#, 262.2, 117#)
shp.TextFrame.TextRange = "News of the Week"

ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

Selection.TypeText Text:="This text appears in the document body.
The other stuff is in the header, but it could be in both header and
footer."
Selection.TypeParagraph
Selection.TypeParagraph

'Add some text
For I = 1 To 5: Selection.TypeText strSomeText: Next

Selection.TypeParagraph
Selection.TypeParagraph
Selection.InsertBreak Type:=wdSectionBreakNextPage

With Selection.PageSetup.TextColumns
.SetCount NumColumns:=3
.EvenlySpaced = True
.LineBetween = True
End With


ActiveDocument.Sections(2).Footers(wdHeaderFooterEvenPages).Range.Text
= "This is in the back/even page footer"


ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader

Set shp = Selection.HeaderFooter.Shapes.AddShape(msoShapeWave,
89.85, 45#, 459#, 45#)
shp.TextFrame.TextRange.Text = "This banner is on the Even pages"
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

For I = 1 To 5: Selection.TypeText strSomeText: Next


Selection.TypeParagraph
End Sub
 
J

Jean-Guy Marcil

Tony Strazzeri said:
Hi aal,

Apologies for the repost (if it appears). I posted a reply but it has
not appeared when I looked for it so heregoes (again).


The following code will create the layout I am referring to.

It contains two sections only so that I can format the first page as
two columns and the second as three. The sections are not needed to
implement the different Odd/Even pages.

The first page has several shapes in the header to simulate possible
graphic/layout elements. The second page has a different banner
across the top. These are in the headers so that the user does not
need to worry about shifting them accidentally.

The main body of the document can just have the text content.

It is up to the user to ensure that the content for each page is
limited to a single page otherwise the text will frlow onto the next
page and carry the column formatting but will of course have the
appropriate odd/even header/banner.

If you want additional sets of layout in the same document you just
need to insert a section break at the end of each page pair and adjust
the column count and headers accordingly. Hope this helps.

Hi Tony,

I have modified your code so as to avoid the Selection object, and,more
importantly, the SeekView bits... SeekView can lead to all kinds of
problems... Try to stay clear...


Option Explicit

Sub DemoTwoPageFlyerLayout()

Dim i As Long
Dim shp As Shape
Dim rgeDoc As Range
Dim rgeAnchor As Range

Const strSomeText = "The quick brown fox jumps over the lazy dog. The quick
brown fox jumps over the lazy dog. " _
& "The quick brown fox jumps over the lazy dog. The quick brown fox
jumps over the lazy dog. " _
& "The quick brown fox jumps over the lazy dog." & vbCr _
& "The quick brown fox jumps over the lazy dog. The quick brown fox
jumps over the lazy dog. " _
& "The quick brown fox jumps over the lazy dog. The quick brown fox
jumps over the lazy dog."

With ActiveDocument.PageSetup
.Orientation = wdOrientPortrait
.OddAndEvenPagesHeaderFooter = True
.DifferentFirstPageHeaderFooter = False
With .TextColumns
.SetCount NumColumns:=2
.EvenlySpaced = True
.LineBetween = False
.Width = CentimetersToPoints(6.99)
.Spacing = CentimetersToPoints(1.27)
End With
End With

Set rgeAnchor =
ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range
rgeAnchor.Collapse

With ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Shapes
Set shp = .AddShape(msoShapeHorizontalScroll, 130, 10#, 380#, 120#,
rgeAnchor)
shpAdjust shp, 130, 10, "This is the banner"
Set shp = .AddShape(msoShapeDoubleBracket, 18.6, 45#, 99.75, 693#,
rgeAnchor)
shpAdjust shp, 18.6, 45, "This could have Addess and contact information."
Set shp = .AddShape(msoShapeFlowchartSequentialAccessStorage, 292.2,
324#, 262.2, 117#, rgeAnchor)
shpAdjust shp, 292.2, 324, "News of the Week"
End With

With ActiveDocument.Sections(1).Footers(wdHeaderFooterEvenPages)
Set rgeAnchor = .Range
rgeAnchor.Collapse
.Range.Text = "This is in the back/even page footer"
Set shp = .Shapes.AddShape(msoShapeWave, 89.85, 45#, 459#, 45#, rgeAnchor)
shpAdjust shp, 89.85, 45, "This banner is on the Even pages"
End With

Set rgeDoc = ActiveDocument.Range
With rgeDoc
.InsertAfter "This text appears in the document body. The other stuff is
in the header, but it could be in both header and footer."
.InsertParagraphAfter
.InsertParagraphAfter
'Add some text
For i = 1 To 5
.InsertAfter strSomeText
Next
.InsertParagraphAfter
.InsertParagraphAfter
.Collapse wdCollapseEnd
.InsertBreak Type:=wdSectionBreakNextPage
End With

With ActiveDocument.Sections(2).PageSetup.TextColumns
.SetCount NumColumns:=3
.EvenlySpaced = True
.LineBetween = True
End With

With rgeDoc
For i = 1 To 5
.InsertAfter strSomeText
Next
.InsertParagraphAfter
End With

End Sub

Function shpAdjust(shpTarget As Shape, sngLeft As Single, _
sngTop As Single, strText As String)

With shpTarget
.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
.RelativeVerticalPosition = wdRelativeHorizontalPositionPage
.LockAnchor = False
.Left = sngLeft
.Top = sngTop
With .WrapFormat
.Type = wdWrapTight
.AllowOverlap = False
End With
.TextFrame.TextRange.Text = strText
End With

End Function


By the way, I may not respond for a while as I do not normally monitor the
vba.beginners group because at work I have to use the MSFT Web Interface, and
MSFT, in their infinite wisodm, have decided not to inlcude vba.beginners,
vba.userforms, etc. within the Office list of discussion groups. Go figure!
I had to do a search to find this post. Strangely, a search gives me access,
but he group itself is not listed in the left margin...
How silly is that?
Very...
 
J

Jean-Guy Marcil

:

By the way, I may not respond for a while as I do not normally monitor the
vba.beginners group because at work I have to use the MSFT Web Interface, and
MSFT, in their infinite wisodm, have decided not to inlcude vba.beginners,
vba.userforms, etc. within the Office list of discussion groups. Go figure!
I had to do a search to find this post. Strangely, a search gives me access,
but he group itself is not listed in the left margin...
How silly is that?
Very...

Now, I have found that if I go to the MSFT Ccommunities Home (not the Office
Community), I have access to more groups...
However, why is it that some groups, like this one, are almost a month
behind, the vba.userforms group is 3 months behind and the vba.addins one is
2 years behind (According tot he Web interface, the last post was in April
2006)!

Why is it that Google can manage to keep all these groups well synchronized,
but the interface MSFT provides cannot even stay synchronized with the
servers in its own company?

Am I doing something wrong?
 
J

Jean-Guy Marcil

Jean-Guy Marcil said:
:



Now, I have found that if I go to the MSFT Ccommunities Home (not the Office
Community), I have access to more groups...
However, why is it that some groups, like this one, are almost a month
behind, the vba.userforms group is 3 months behind and the vba.addins one is
2 years behind (According tot he Web interface, the last post was in April
2006)!

Why is it that Google can manage to keep all these groups well synchronized,
but the interface MSFT provides cannot even stay synchronized with the
servers in its own company?

Am I doing something wrong?

Sorry about all this... Indeed I was...

I noticed that the address in the URL field in the address bar in my browser
was full of code. Once I cleaned it up and reduced the address text to a bare
minimum, I got all the latest posts in all groups. I guess that somehow some
filtering code got attached to the address...

I just had to create my own bookmarks though because when you navigate from
group to group with the MSFT list of groups in the left frame on the web
page, it resets itself everytime. Then you have to expand the whole hierarchy
to get to the group you want everytime you want to change groups... quite
cumbersome...

I miss my OE/QuoteFix combo... snif.

But now I have access to more groups than I did when I navigated exclusively
with the Office commnity page.

Now I'll do like some poster did in another group... I'll gloat at my own
success in working out my own self-made problems...

Cheers and sorry to have polluted the groups with my rants...
 

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