Solved

active sheet powerpoint

Posted on 2015-02-05
11
245 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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
 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
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 create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

776 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