Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Working with Horizontal and Vertical Slides

Powerpoint

Working with Horizontal and Vertical Slides

by  Chance1234  Posted    (Edited  )
This was the business case i had for the following.

Powerpoint was being used by company A to produce sales books from a set of templates they had.

These sales books contain slides which were both vertical and horizontal orientation
This was acheived by a manual process of creating two presentations (one horizontal, one vertical)
Printing them out , and then a member of staff sorting out the order. This also left two ppt files
containg the information in no sensible order.

This was the solution i came up.

Firslty i created two powerpoint presenations containg the templates, One for horizontal , one for vertical templates

I then used a third presentation for my code, which looked something like this


Code:
'Global pp_Final As Presentation  ' Presenation we are creating

Global pp_Tools As Presentation ' This Presentation
Global pp_Vert As Presentation ' All Vertical Slides
Global pp_Horiz As Presentation ' All Horizontal slides
Global sld_cnt as integer 'slide counter

Global Const str_TempPath As String = "C:\sales_books\"

Sub CutdownExampleForFAQCreatingNewPresentation


'Reference the horizontal and vertical slides 
Set pp_Vert = Application.Presentations.Open(str_TempPath & "PackVertical.ppt", , msoFalse, msoFalse)
Set pp_Horiz = Application.Presentations.Open(str_TempPath & "PackHoriz.ppt", , msoFalse, msoFalse)
   
Sld_Cnt = 1

'create a new presentation
Set pp_Final = Application.Presentations.Add
'Page set up
With pp_Final
    .PageSetup.SlideOrientation = msoOrientationMixed
    .PageSetup.SlideSize = ppSlideSizeA4Paper
End With

'In my original code i used a series of Select cases to decide what 
'was needed in the final tax pack and there was a lot more processing involved
' this is cut down so apologies for any errors but hopefully it will give you 
' enough to see whats happening.

'Firstly I add in a Vertical Slide

pp_Vert.Slides("sld_Cover").Copy
pp_Final.Slides.Paste
Sld_Cnt = Sld_Cnt + 1 'update counter

Set sld_Temp = pp_Final.Slides(Sld_Cnt) ' Select the slide
sld_Temp.Tags.Add "O", "V"

'Then a horizontal 

pp_Horiz.Slides("sld_Map").Copy
pp_Final.Slides.Paste

Sld_Cnt = Sld_Cnt + 1 'update counter
Set sld_Temp = pp_Final.Slides(Sld_Cnt) ' Select the slide
sld_Temp.Tags.Add "O", "H"

'I now want to add in another Vertical Slide 

pp_Vert.Slides("sld_Sales").Copy
pp_Final.Slides.Paste
Sld_Cnt = Sld_Cnt + 1 'update counter

End sub

Now what the above has done, has created a new presenation with 3 slides in it, One Vertival ,One Horizontal and Another Vertical

If you look at the presentation as it, you will see everything in the default page layout. Which is no good to us

IF you look at the above code, i used a tag property called O which stores a value of V for vertical slide and H for horizontal slides.

To Print my slides out in the correct orientation i used the following code


Code:
Public Sub CutDownProcess()

Dim var As Slide
Dim str_tpath As String
Dim str_A As String

'change orientation on tag and print out 

For Each var In pp_Final.Slides
 
 select case var.tag("O") 
 
	case "V"
		pp_Final.PageSetup.SlideOrientation = msoOrientationVertical
	case "H"
		pp_Final.PageSetup.SlideOrientation = msoOrientationHorizontal
	
end select

      pp_Final.PrintOut var.slideindex,var.slideindex
    
Next


End Sub

Presentation printed out correctly in order and stored in one place.

I did take this a stage further by at the same time of printing, creating a GIF of the slide using the export function and saving that down into a directory

code looked something like this

Code:
    Select Case strType
    
        Case "H"
         pp_Final.PageSetup.SlideOrientation = msoOrientationHorizontal
            Pixwidth = 1110
            Pixheight = 870
        Case "V"
        pp_Final.PageSetup.SlideOrientation = msoOrientationVertical
            Pixwidth = 870
            Pixheight = 1110
            
    End Select
    
    ExportPath = str_pth

    Set oSlide = pp_Final.Slides(int_sld)
    With oSlide
        .Export ExportPath & "Slide" & CStr(.SlideIndex) & ".GIF", "GIF", Pixwidth, Pixheight
    End With


I then used a bit of javescript and html to enable someone to view that on screen in correct order ,

Another option is to put the slideorientation code above onto a button for next slide and , when someone plays
the slide show you can flip the orientation.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top