Changeable backdrop and page numbering

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

Changeable backdrop and page numbering

Post by Robie »

Hi

PowerPoint templates creation.

This is same question as per Word really (which Hans & Stuart answered) but this time with PowerPoint. Unfortunately, I am not very familiar with PP.

Basically, I need to have 1st slide with changeable triangle as a back drop (which I presume I can achieve the change of colours using VBA as per Word).
rebranding 1st slide.png
2nd and subsequent slides to have the page numbering on top of a changeable triangle (same colour as the 1st slide large triangle). I don't know how to get the autoshape on the footer so that it is *repeated* for all slides except the 1st slide. The header/footer defintion is different in PP compared to Word.
rebranding 2nd slide.png
I am sure you guys know how to achieve this easily :0).

Thanks

Robie
You do not have the required permissions to view the files attached to this post.

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

Re: Changeable backdrop and page numbering

Post by HansV »

Which version of PowerPoint?
Best wishes,
Hans

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

Re: Changeable backdrop and page numbering

Post by Robie »

HansV wrote:Which version of PowerPoint?
2003 at the moment but in future we may go to 2010 (perhaps in 18 months or so).

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

Re: Changeable backdrop and page numbering

Post by HansV »

OK. You can create a separate title master and slide master. The title master will be used for the title slide and the slide master for all other slides (in PowerPoint 2010 it's much more flexible AND complicated).

Create the big triangle on the title master and name it TitleTriangle. Make sure you send it to the back so that it will be behind the text.
Create the small triangle over the page number on the slide master and name it SlideTriangle. Send this to the back too.

See if this code does what you want (I can't test it in PowerPoint 2003 at the moment):

Code: Select all

Private Declare Function ChooseColor Lib "comdlg32.dll" Alias "ChooseColorA" (pColorStruct As ColorStruct) As Long

Private Const CC_RGBINIT = &H1

Private Type ColorStruct
  lStructSize As Long
  hwndOwner As Long
  hInstance As Long
  rgbResult As Long
  lpCustColors As String
  flags As Long
  lCustData As Long
  lpfnHook As Long
  lpTemplateName As String
End Type

Function ShowColor(Optional lngColor As Long) As Long
  Dim cc As ColorStruct
  Dim CustomColors() As Byte
  Dim i As Integer
  ReDim CustomColors(0 To 16 * 4 - 1) As Byte
  For i = LBound(CustomColors) To UBound(CustomColors)
    CustomColors(i) = 0
  Next i

  'set the structure size
  cc.lStructSize = Len(cc)
  'Set the owner
  
  cc.hwndOwner = 0
  'set the application's instance
  cc.hInstance = 0
  'set the custom colors (converted to Unicode)
  cc.lpCustColors = StrConv(CustomColors, vbUnicode)
  'no extra flags
  cc.flags = CC_RGBINIT
  'set color
  cc.rgbResult = lngColor

  'Show the 'Select Color'-dialog
  If ChooseColor(cc) <> 0 Then
    ShowColor = cc.rgbResult
    'CustomColors = StrConv(cc.lpCustColors, vbFromUnicode)
  Else
    ShowColor = -1
  End If
End Function

Sub AskColour()
  Dim lngColour As Long
  lngColour = ActivePresentation.TitleMaster.Shapes("TitleTriangle").Fill.ForeColor.RGB
  lngColour = ShowColor(lngColour)
  If lngColour <> -1 Then
    ActivePresentation.TitleMaster.Shapes("TitleTriangle").Fill.ForeColor.RGB = lngColour
    ActivePresentation.SlideMaster.Shapes("SlideTriangle").Fill.ForeColor.RGB = lngColour
  End If
End Sub
Run the macro AskColour to set the colour of the triangles.
Best wishes,
Hans

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

Re: Changeable backdrop and page numbering

Post by Robie »

HansV wrote:OK. You can create a separate title master and slide master. The title master will be used for the title slide and the slide master for all other slides (in PowerPoint 2010 it's much more flexible AND complicated).

Create the big triangle on the title master and name it TitleTriangle. Make sure you send it to the back so that it will be behind the text.
Create the small triangle over the page number on the slide master and name it SlideTriangle. Send this to the back too.

See if this code does what you want (I can't test it in PowerPoint 2003 at the moment):

Code: Select all

Private Declare Function ChooseColor Lib "comdlg32.dll" Alias "ChooseColorA" (pColorStruct As ColorStruct) As Long

Private Const CC_RGBINIT = &H1

Private Type ColorStruct
  lStructSize As Long
  hwndOwner As Long
  hInstance As Long
  rgbResult As Long
  lpCustColors As String
  flags As Long
  lCustData As Long
  lpfnHook As Long
  lpTemplateName As String
End Type

Function ShowColor(Optional lngColor As Long) As Long
  Dim cc As ColorStruct
  Dim CustomColors() As Byte
  Dim i As Integer
  ReDim CustomColors(0 To 16 * 4 - 1) As Byte
  For i = LBound(CustomColors) To UBound(CustomColors)
    CustomColors(i) = 0
  Next i

  'set the structure size
  cc.lStructSize = Len(cc)
  'Set the owner
  
  cc.hwndOwner = 0
  'set the application's instance
  cc.hInstance = 0
  'set the custom colors (converted to Unicode)
  cc.lpCustColors = StrConv(CustomColors, vbUnicode)
  'no extra flags
  cc.flags = CC_RGBINIT
  'set color
  cc.rgbResult = lngColor

  'Show the 'Select Color'-dialog
  If ChooseColor(cc) <> 0 Then
    ShowColor = cc.rgbResult
    'CustomColors = StrConv(cc.lpCustColors, vbFromUnicode)
  Else
    ShowColor = -1
  End If
End Function

Sub AskColour()
  Dim lngColour As Long
  lngColour = ActivePresentation.TitleMaster.Shapes("TitleTriangle").Fill.ForeColor.RGB
  lngColour = ShowColor(lngColour)
  If lngColour <> -1 Then
    ActivePresentation.TitleMaster.Shapes("TitleTriangle").Fill.ForeColor.RGB = lngColour
    ActivePresentation.SlideMaster.Shapes("SlideTriangle").Fill.ForeColor.RGB = lngColour
  End If
End Sub
Run the macro AskColour to set the colour of the triangles.
Thanks very much Hans. :clapping: Have a good weekend.

I will try it out on Monday. Just getting to grips with PP - never really created any templates for it. Just used to Word.

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

Re: Changeable backdrop and page numbering

Post by Robie »

Need further help please.

Is there any way of adding more 'Subtitle area' textboxes to the master slide and possibly same question for the 'subsequent slides'? At the moment, in design mode I have two text boxes; 'Title area for Autolayouts' and 'Subtitle area for Autolayouts'.

I need to add text with different styles as the user adds more lines to the main slide.
rebranding master style.png
Thanks.
Robie.
You do not have the required permissions to view the files attached to this post.

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

Re: Changeable backdrop and page numbering

Post by HansV »

You can't add new placeholders in PowerPoint 2003, I think you can in PowerPoint 2010.

For subsequent slides, you don't add new placeholders - you can edit the Second level, third level etc. text in the slide master:
x455.jpg
For the title slide, you'll have to live with the title and subtitle in PowerPoint 2003.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

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

Re: Changeable backdrop and page numbering

Post by Robie »

Thanks Hans.

Title slide - no extra placeholders. Bad news - I guess we will just have to change how it looks.
Other slides - same.

I will have to think about this one bit more.

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

Re: Changeable backdrop and page numbering

Post by Robie »

Hi Hans

Your code works perfectly if run either under debug or by selection the macro through the menu.

But doesn't work if I add it to a toolbar in a template - very odd. Don't understand that :0?
tbdoesnotwork.png
Robie
You do not have the required permissions to view the files attached to this post.

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

Re: Changeable backdrop and page numbering

Post by HansV »

I tried it and it works OK for me.

Do you get an error message or doesn't the button do anything at all?
Best wishes,
Hans

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

Re: Changeable backdrop and page numbering

Post by Robie »

HansV wrote:I tried it and it works OK for me.

Do you get an error message or doesn't the button do anything at all?
It doesn't do anything :-(. No error messages or error codes of any kind. I have even put msgbox just to see if it goes in to the code but nothing is displayed on the screen. Almost as if it is not being called. All the security settings have been changed to low - just for testing (although in real they would be at medium).

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

Re: Changeable backdrop and page numbering

Post by HansV »

Sorry, I can't explain that. If you wish, you can attach a stripped down and zipped copy of the presentation/template.
Best wishes,
Hans

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

Re: Changeable backdrop and page numbering

Post by Robie »

HansV wrote:Sorry, I can't explain that. If you wish, you can attach a stripped down and zipped copy of the presentation/template.
Thanks Hans. Here is my template. I removed all the company related stuff and with only one macro.
You do not have the required permissions to view the files attached to this post.

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

Re: Changeable backdrop and page numbering

Post by HansV »

That's because the button is linked to the template but - unlike in Word - the template isn't open when you create or open a presentation based on the template.
You'll have to put the code in a PowerPoint add-in (.ppa).
Please read Create an ADD-IN with TOOLBARS that run macros carefully before creating the add-in. In particular, heed the warning that you MUST save the presentation as a .ppt before saving as a .ppa, for there is no way to edit a .ppa. So if you have to modify anything, you must edit the .ppt, save it, then also save it as a .ppa.
Best wishes,
Hans

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

Re: Changeable backdrop and page numbering

Post by Robie »

HansV wrote:That's because the button is linked to the template but - unlike in Word - the template isn't open when you create or open a presentation based on the template.
You'll have to put the code in a PowerPoint add-in (.ppa).
Please read Create an ADD-IN with TOOLBARS that run macros carefully before creating the add-in. In particular, heed the warning that you MUST save the presentation as a .ppt before saving as a .ppa, for there is no way to edit a .ppa. So if you have to modify anything, you must edit the .ppt, save it, then also save it as a .ppa.
Thanks Hans. I will create a .ppa file and try it out.

Better to avoid the assumptions regarding how it operates (would have thought it would same for all Microsoft products). I am sure there is a reason why it is different.

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

Re: Changeable backdrop and page numbering

Post by HansV »

Each Office application is developed by a separate team, and each has its own history. There is obviously some cross-fertilization but the differences remain large.
Best wishes,
Hans