I'm working on a VB powerpoint tool. From Powerpoint Normal View when I select (click) a slide in the Left-hand Pane, if I don't click on the Slide Pane (the pane displaying a large view of the current slide), this Code line will not work.
Application.ActivePresentation.Windows(1).PointsToScreenPixelsY(0)
I got the following error message : "DocumentWindow(unknown member) : Illegal value."
Is there a way with VB to click on the Slide Pane?
I know it's late, but just in case anyone else lands here like me for the same problem, here is how to solve it:
If ActiveWindow.ViewType = PpViewType.ppViewNormal AndAlso Then
ActiveWindow.Panes(2).Activate()
End If
That is, you must activate the main slide pane (not the list of slides) before performing any actions, e.g. selection.
Related
I am a beginner at VBA.
I am designing a somewhat interactive Powerpoint presentation/s. I want to be able to have three separate Powerpoint presentations open that will link together. I have been trying (without success) to create, in VBA, code which will change the current displayed slide on one Powerpoint file by clicking a button in another. I can hyperlink to the set slide but this causes this slide to pop up on the same screen in which it is clicked, despite it being already open in another screen (I don't want this).
Thanks in advance for any help,
Holly
VBA uses an object model that is a huge hierarchy of attributes and functions that represent the application. You can use this model to view and update attributes to get text, resize, and modify the application. You should look at some tutorials to get you started. When editing your code, you can press F2 to see and explore this object model. You can press F8 to run your code line by line (debug mode) and see what is happening.
To your question, you can access the open presentations in the application.presentations object (https://learn.microsoft.com/en-us/office/vba/api/powerpoint.presentations). You could then use a presentation in that list and use the ActiveWindow.View.goToSlide function (https://learn.microsoft.com/en-us/office/vba/api/powerpoint.view.gotoslide). Here is a free tutorial that I've used in my VBA journey (https://www.tutorialspoint.com/vba/index.htm).
PowerPoint has a Presentations collection that contains all currently open presentations. You can get a reference to any of them via Presentations("name") where "name" is the filename of the presentation, sans extension.
So ... assuming you've got three presentations open, a.pptx, b.pptx, c.pptx you can do something like this:
Sub SlideChange()
With Presentations("c")
.SlideShowWindow.View.GotoSlide (3)
End With
End Sub
If you run the above in any of the presentations, it will change the slide show window displaying presentation c to the third slide.
I would like a VBA script that does the following:
Changes all slide Line Spacing to Single
Changes all slide Spacing Before and After to 0
My research online so far hasn't been successful and any test runs have come back with errors.
I discovered a solution that doesn't require VBA/Macros. If using PowerPoint 2016, under the View tab, choose Outline View. Here you can select all the slides with Ctrl + A, and now go to Home, click the small arrow in the Paragraph section and you can change the settings for all slides there. You must be in Outline View mode to do this as otherwise, PowerPoint won't let you change paragraph settings for more than one slide at a time.
In PowerPoint 2013, the Selection pane properties are available from a CommandBar object as follows:
Application.CommandBars("Selection")
(note that for PowerPoint 2010 and 2007 the name is "Selection and Visibility")
When using Alt+F10 in the UI to show the Selection Pane, the following two properties are toggled to true:
Application.CommandBars("Selection").Visible
Application.CommandBars("Selection").Enabled
However, when attempting to set these to true programmatically, the .Visible=True statement causes an unspecified automation error to occur and the .Enabled=True statement executes but doesn't change the state of this property.
But, and this is the weird part, if Alt+F10 is used to show and hide the Selection Pane when PowerPoint first runs, the two lines of code work! I checked all the properties before and after Alt+F10 and only the .Visible and .Enabled ones are toggled.
How can I show the Selection Pane reliably and preferably without having to go down the SendKeys route?
If you just want to show it try:
If Not CommandBars.GetPressedMso("SelectionPane") Then CommandBars.ExecuteMso ("SelectionPane")
I think this is a simple question, but I have spent days searching for an answer and nothing yet.
I have an OLE object embedded into a PowerPoint presentation (created using PPT 2010). I embedded it (a pdf file) through the insert>object>create from file>display as icon method, so that it displays as a little icon on a slide.
My goal is to open it on click of a shape, where the shape is on a different slide from the slide the pdf is on. The pdf is on slide 5, the trigger shape is on slide 6. The goal is to open it during slideshow viewing (and it must be done through VBA instead of animations for other reasons).
I thought the following would work:
Sub OpenMyDoc()
ActivePresentation.Slides(5).Shapes("My Doc").OLEFormat.DoVerb(1)
End Sub
I had assigned that macro as an on click "action" through the insert>links method.
I have also tried the following variations, with no luck (nothing happens at all when I click on the triggering shape):
ActivePresentation.SlideShowWindow.View.Slide.Shapes("My Doc").OLEFormat.DoVerb(1)
I also tried:
With SlideShowWindows(1).Presentation.Slides(5).Shapes("My Doc")
OLEFormat.DoVerb(1)
End With
I also tried:
ActivePresentation.Slides.Item(5).Shapes.Item("My Doc").OLEFormat.DoVerb(1)
Other macros (mostly message boxes) in the presentation, and on the same slide work, so I'm sure it's not a permissions or other setting issue.
I am using master slides, but can't seem to trace the problem to that.
You probably saw an error message when you ran your code; the error message explains the problem, though in somewhat Microsoftcryptic fashion. You can only activate OLE objects from Slide or Notes view.
Instead, you can do this:
ActivePresentation.Slides(1).Shapes(4).ActionSettings(1).Hyperlink.Follow
where Shapes(4) is hyperlinked to the PDF you want to launch.
[EDIT]
But since hyperlinking isn't an option, and since you have to be in slide view to activate the embedded object, this works here:
' Activate the presentation window
' You might need to make sure it's in normal view
ActivePresentation.Windows(1).Activate
' Launch the OLE object:
ActivePresentation.Slides(1).Shapes(1).OLEFormat.DoVerb (1)
' And immediately switch back to slide show view
SlideShowWindows(1).Activate
Using Powerpoint 2010, we are developing a touchscreen application to be displayed in the Kiosk mode.
Now I have here a powerpoint slide with a transparent,invisible shape that has a hyperlink to a PDF File.
On click, the Acrobat Reader opens and shows a PDF file. So far, so good.
However, if someone moves the mouse pointer or the finger over the button (+ transparent shape), there always appears a big tooltip displaying the filename, such as "\mypath\longsubdir\myfile.pdf" - and this tooltip is really annoying.
Is there a way to hide the tooltip? There does not seem to be an easy way to hide it, using the context menu of the hyperlinked shape.
Or should I try some workaround (using transparent command buttons instead of shapes, or similar. Using the VBA APi of the shape...)
Well, I don't have powerpoint 2010 but 2007 here, but when I create a shape, click on the hyperlink button, following screen appears (or something similar at least):
Image link, can not post images yet.(no popups)
In the top right corner, you have a button "Screentip". Click this button, fill in a space or even nothing at all and your screentip will only show up empty.
Or if you indeed want to truly remove the tooltip altogether, then I do recommend to use some vba/macro. Create a new macro, insert these lines of code:
Dim myShell As Object
Set myShell = CreateObject("WScript.Shell")
myShell.Run "C:\MyPDF.pdf"
Change the path to the pdf of course. Then add an action to your shape and link it to the macro that you created.
Powerpoint already has an option that hides all screen tips.
Go to the menu: [File - Option - General], Under 'User interface option'
Change the 'ScreenTips style' option to 'Don't Show ScreenTips'
or You can try the following macro code
to force all ScreenTips to just show 'little blank circles':
Sub ForceScreenTipsToBlank()
Dim sld As Slide
Dim lnk As Hyperlink
For Each sld In ActivePresentation.Slides
For Each lnk In sld.Hyperlinks
lnk.ScreenTip = vbCr 'or " " to show blank
Next lnk
Next sld
End Sub
Unfortunately, Changing to [lnk.ScreenTip=""] doesn't remove screen-tips.
You have to re-add hyperlinks with no ScreenTip or manually remove ScreenTips in the dialog box.