Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Activate PowerPoint Window from Excel using VBA

Status
Not open for further replies.

work4livinsean

Programmer
Mar 28, 2006
23
US
Hello everyone, I am having a problem activating a powerpoint window from a VBA in excel. I have a couple pieces of code but nothing happens when I run it. Can someone please help me with this, thanks:

Sub ChangeToPower()

Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide

UpdateScreen = True

' Reference existing instance of PowerPoint
Set PPApp = GetObject(, "Powerpoint.Application")
' Reference active presentation
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewSlide
' Reference active slide
Set PPSlide = PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)

'**Here are 3 things I have tried, cannot get any to work right**
PPApp.ActiveWindow("Filename.ppt").Activate
PPPres.Windows(1).Activate
PPSlide.Application.Windows(1).Activate

End Sub

Thanks in advance.
 
Also, there is a lot more that I need than just to be viewing the screen. What I wanted to do was allow the user to select a slide, and then that would copy and paste an excel range onto the slide. I have the code to copy and paste complete and even have an input box for this. Currently, I let the user type in a number for the slide he/she wants the excel range to be pasted onto. I would much rather have him/her be able to view PowerPoint and click a slide. That would then update the slide to paste the excel range to. I want to use an input box for this but I don't know if I can do that in PowerPoint. Here is a code I am using to select ranges which updates the ranges in the input box:

Sub UpdateRangeInput()

Dim UserRange As Range

Prompt = "Please Make Your Selection"
Title = "Select Your Range"

' Display the Input Box
On Error Resume Next
Set UserRange = Application.InputBox(Prompt:=Prompt, Title:=Title, Default:=ActiveCell.Address, Type:=8) 'Range selection

If UserRange Is Nothing Then
MsgBox "Cancelled."
Else
'Do some code based on UserRange
End If

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top