Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

active sheet powerpoint

Posted on 2015-02-05
11
Medium Priority
?
325 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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

705 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