Solved

active sheet powerpoint

Posted on 2015-02-05
11
308 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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 46

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 12

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Add visuals to your Prezi to keep your audience engaged. Learn how to embed images, edit them, and more in this video micro tutorial. Select "Insert" from the top menu in your Prezi editor: Select "Image": A toolbar will pop in from the right …

627 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