Solved

active sheet powerpoint

Posted on 2015-02-05
11
208 Views
Last Modified: 2016-02-10
In powerpoint

need to know how to modify the below code to print the active page.
instead of .Add Start:=46, End:=46
i need .add start:=activepage, end:=activepage

below is the whole code.

Private Sub CommandButton1_Click()
    CommandButton1.Visible = False
    With ActivePresentation.PrintOptions
        .RangeType = ppPrintSlideRange
        With .Ranges
            .ClearAll
            .Add Start:=46, End:=46
        End With
        .NumberOfCopies = 1
        .Collate = msoTrue
        .OutputType = ppPrintOutputSlides
        .PrintHiddenSlides = msoTrue
        .PrintColorType = ppPrintColor
        .FitToPage = msoFalse
        .FrameSlides = msoFalse
    
    End With
    ActivePresentation.PrintOut
    CommandButton1.Visible = True
End Sub

Open in new window

0
Comment
Question by:rjef
11 Comments
 
LVL 24

Expert Comment

by:Phillip Burton
Comment Utility
Change

.Add Start:=46, End:=46

to

.Add Start:=Application.ActiveWindow.View.Slide.SlideIndex, End:=Application.ActiveWindow.View.Slide.SlideIndex
0
 

Author Comment

by:rjef
Comment Utility
is says there is no active window
0
 

Author Comment

by:rjef
Comment Utility
see error in attachment

no active window
no-active-window.jpg
0
 
LVL 24

Expert Comment

by:Phillip Burton
Comment Utility
I can't see the rest of the window.
0
 

Author Comment

by:rjef
Comment Utility
the rest of the window is just the sheet i want to print
see attached
error.jpg
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 45

Expert Comment

by:aikimark
Comment Utility
maybe your slides are losing focus when you click on the Print button.
0
 
LVL 24

Expert Comment

by:Phillip Burton
Comment Utility
Are you in slideshow?
0
 
LVL 9

Expert Comment

by:Jamie Garroch
Comment Utility
Because you are running the macro from a slide show (the only way an ActiveX Control can work on a slide) you need to use a different reference to the active slide so change the .Add line to this:

.Add Start:=ActivePresentation.SlideShowWindow.View.Slide.SlideIndex, _
         End:=ActivePresentation.SlideShowWindow.View.Slide.SlideIndex

Open in new window


I would also recommend you use a shape rather than an ActiveX control to trigger the macro for the following reasons:

1. Because ActiveX controls cause all sorts of verbose security messages to appear when you transfer the file to other user. We always digitally sign our VBA projects to minimise this issue.
2. Using a shape also gives you much better control of how the "button" looks and you can style it to match the branding in your presentation.
3. The code resides in a standard VBA Project module which won't be deleted should the slide get deleted.
0
 
LVL 23

Accepted Solution

by:
JSRWilson earned 500 total points
Comment Utility
Use a normal shape (not activX) to run the macro (Insert >> Action >> Run Macro

This is the code

Sub PrintMe(oshp As Shape)
Dim curr As Long
oshp.Visible = False
curr = SlideShowWindows(1).View.CurrentShowPosition
    With ActivePresentation.PrintOptions
        .RangeType = ppPrintSlideRange
        With .Ranges
            .ClearAll
            .Add Start:=curr, End:=curr
        End With
        .NumberOfCopies = 1
        .Collate = msoTrue
        .OutputType = ppPrintOutputSlides
        .PrintHiddenSlides = msoTrue
        .PrintColorType = ppPrintColor
        .FitToPage = msoFalse
        .FrameSlides = msoFalse
    
    End With
    ActivePresentation.PrintOut
    oshp.Visible = True
End Sub

Open in new window

0
 

Author Closing Comment

by:rjef
Comment Utility
thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Not everyone is tied to the Microsoft Office suite these days, as more free cloud-based solutions are entering the market. You might be used to creating presentations in PowerPoint, but did you know Google offers Slides  (https://www.google.com/slid…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Learn the basics of inputting and editing your text components in Prezi. We will cover how to set styles, position, and group your text components. In your Prezi editor, click anywhere on the canvas to add text: A flashing cursor informs you that yo…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now