Randomly changeable front cover

Robie
5StarLounger
Posts: 656
Joined: 18 Feb 2010, 14:26

Randomly changeable front cover

Post by Robie »

Hi

As part of the company rebranding exercise, we have been asked to change the front cover on our templates. Basically, the backdrop needs to be randomly generated with different colours when the document is *created*. More details in the attachment.
rebranding - front cover.png
Any ideas highly welcomed. Thanks.

Robie.

EDIT: This will most likely be used with Windows 7 and Office 2007/2010 or Office 2003.
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78487
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Randomly changeable front cover

Post by HansV »

Keep in mind that most printers don't allow printing right up to the edge of the paper, and that printing solid blocks of colour uses up enormous amounts of toner and often produces disappointing results. It'd be better to buy coloured paper if the right design is available, or have it produced for you by a professional print shop. You can then print text on top of the coloured cover paper.
Best wishes,
Hans

User avatar
StuartR
Administrator
Posts: 12605
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Randomly changeable front cover

Post by StuartR »

You could give the colored triangle a name and then set the forecolor of that object in a document_new procedure associated with the template.

Code: Select all

Private Sub Document_New()    
    Select Case Int(Rnd * 6)
        Case 1
            ActiveDocument.Shapes("shpColorTriangle").Fill.ForeColor = RGB(127, 255, 0)
        Case 2
            ActiveDocument.Shapes("shpColorTriangle").Fill.ForeColor = RGB(127, 0, 255)
        Case 3
            ActiveDocument.Shapes("shpColorTriangle").Fill.ForeColor = RGB(0, 127, 255)
        Case 4
            ActiveDocument.Shapes("shpColorTriangle").Fill.ForeColor = RGB(0, 255, 127)
        Case 5
            ActiveDocument.Shapes("shpColorTriangle").Fill.ForeColor = RGB(255, 0, 127)
        Case 6
            ActiveDocument.Shapes("shpColorTriangle").Fill.ForeColor = RGB(0, 60, 60)
    End Select
End Sub
This won't help if people simply copy an existing front cover to use.

I have uploaded a template in a zip file for you to play with.
Front Cover.zip
You do not have the required permissions to view the files attached to this post.
StuartR


Robie
5StarLounger
Posts: 656
Joined: 18 Feb 2010, 14:26

Re: Randomly changeable front cover

Post by Robie »

HansV wrote:Keep in mind that most printers don't allow printing right up to the edge of the paper, and that printing solid blocks of colour uses up enormous amounts of toner and often produces disappointing results. It'd be better to buy coloured paper if the right design is available, or have it produced for you by a professional print shop. You can then print text on top of the coloured cover paper.
Thanks Hans. My argument exactly with the management but they are adamant that they want this. Personally, I would prefer it without this mess of solid blocks & as you say it does use of lots of toner.

Robie
5StarLounger
Posts: 656
Joined: 18 Feb 2010, 14:26

Re: Randomly changeable front cover

Post by Robie »

StuartR wrote:You could give the colored triangle a name and then set the forecolor of that object in a document_new procedure associated with the template.

Code: Select all

Private Sub Document_New()    
    Select Case Int(Rnd * 6)
        Case 1
            ActiveDocument.Shapes("shpColorTriangle").Fill.ForeColor = RGB(127, 255, 0)
        Case 2
            ActiveDocument.Shapes("shpColorTriangle").Fill.ForeColor = RGB(127, 0, 255)
        Case 3
            ActiveDocument.Shapes("shpColorTriangle").Fill.ForeColor = RGB(0, 127, 255)
        Case 4
            ActiveDocument.Shapes("shpColorTriangle").Fill.ForeColor = RGB(0, 255, 127)
        Case 5
            ActiveDocument.Shapes("shpColorTriangle").Fill.ForeColor = RGB(255, 0, 127)
        Case 6
            ActiveDocument.Shapes("shpColorTriangle").Fill.ForeColor = RGB(0, 60, 60)
    End Select
End Sub
This won't help if people simply copy an existing front cover to use.

I have uploaded a template in a zip file for you to play with.
Front Cover.zip
Thanks Stuart, I think you are on to a winner here. I will certainly play with your template.

This sounds like a really good solution to me apart from the creation and adding of the triangular shape. But, I will look into that - google will be my best friend for a while :0).

User avatar
StuartR
Administrator
Posts: 12605
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Randomly changeable front cover

Post by StuartR »

Robie wrote:...This sounds like a really good solution to me apart from the creation and adding of the triangular shape...
I created the three shapes manually, and then set the name of the third shape using the Visual Basic immediate window.

Because I had created exactly three shapes, I just used the command
ActiveDocument.Shapes(3).Name = "shpColorTriangle"
StuartR


User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: Randomly changeable front cover

Post by agibsonsw »

Won't Int(Rnd*6) produce a number between 0 and 5? It's a little neater (more efficient) to nest the Select.. Case within a With structure:

Code: Select all

Private Sub Document_New()
    With ActiveDocument.Shapes("shpColorTriangle").Fill
        Select Case Int(Rnd * 6 + 1)
            Case 1
                .ForeColor = RGB(127, 255, 0)
            Case 2
                .ForeColor = RGB(127, 0, 255)
            Case 3
                .ForeColor = RGB(0, 127, 255)
            Case 4
                .ForeColor = RGB(0, 255, 127)
            Case 5
                .ForeColor = RGB(255, 0, 127)
            Case 6
                .ForeColor = RGB(0, 60, 60)
        End Select
    End With
End Sub
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

User avatar
StuartR
Administrator
Posts: 12605
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Randomly changeable front cover

Post by StuartR »

agibsonsw wrote:Won't Int(Rnd*6) produce a number between 0 and 5?
Yes, of course it will.
agibsonw wrote:It's a little neater (more efficient) to nest the Select.. Case within a With structure:
Thanks for the corrections, that code is much better.
StuartR


Robie
5StarLounger
Posts: 656
Joined: 18 Feb 2010, 14:26

Re: Randomly changeable front cover

Post by Robie »

Thank you all. :clapping:

The solution you have provided works just wonderfully for me. You are all too good. A big THANKS.