INTELLIGENT WORK FORUMS FOR COMPUTER PROFESSIONALS
Log In
Come Join Us!
Are you a Computer / IT professional? Join Tek-Tips Forums!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- One-Click Access To Your
Favorite Forums
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Posting Guidelines
Promoting, selling, recruiting, coursework and thesis posting is forbidden. Students Click Here
|
VBA Visual Basic for Applications (Microsoft) FAQ
Powerpoint
Working with Horizontal and Vertical Slides by Chance1234
Posted: 23 Mar 06
|
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
CODEPublic 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.
|
Back to VBA Visual Basic for Applications (Microsoft) FAQ Index
Back to VBA Visual Basic for Applications (Microsoft) Forum |
|
|
|
Join Tek-Tips® Today!
Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.
Here's Why Members Love Tek-Tips Forums:
Talk To Other Members
- Notification Of Responses To Questions
- Favorite Forums One Click Access
- Keyword Search Of All Posts, And More...
Register now while it's still free!
Already a member? Close this window and log in.
Join Us Close