Solved

active sheet powerpoint

Posted on 2015-02-05
11
231 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
ID: 40591287
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
ID: 40591381
is says there is no active window
0
 

Author Comment

by:rjef
ID: 40591405
see error in attachment

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

Expert Comment

by:Phillip Burton
ID: 40591407
I can't see the rest of the window.
0
 

Author Comment

by:rjef
ID: 40591773
the rest of the window is just the sheet i want to print
see attached
error.jpg
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 45

Expert Comment

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

Expert Comment

by:Phillip Burton
ID: 40593190
Are you in slideshow?
0
 
LVL 10

Expert Comment

by:Jamie Garroch
ID: 40596703
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
ID: 40596758
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
ID: 40623779
thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
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…
It’s easy to embed any of your public Prezi presentations on your website or social network to share with others. Learn how simple it is in this tutorial.

910 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

20 Experts available now in Live!

Get 1:1 Help Now