PDA

View Full Version : Open userform in powerpoint from excel



Jhon90
07-07-2021, 11:17 PM
Sir,
I have an Userform in PowerPoint say Userform1. Now I want to open this userform1 from excel sheet(command button). But below code is not working.
NOTE: Frist I opened PowerPoint & then pressed command button in excel.



Sub showUserForm()
Dim PowerPointApp As Object
Set PowerPointApp = GetObject(Class:="Powerpoint.application")
PowerPointApp.Run (PowerPointApp.ActivePresentation.Name & "!UserForm1.Show")
End Sub

SamT
07-08-2021, 07:42 AM
I don't do PP, but maybe something like:

Dim PPfile as Object
Set PPFile = PowerPointApp.Open(PPFullFileName)
PPFile.PPSubName
Where PPFullFileName is the path and name to the pp file and PPSubName is the Name of a Procedure in the PP file that shows the UserForm in the PP File.


Public Sub PPSubName()
UserForm1.Show
End Sub


GetObject(Class:="Powerpoint.application") Opens a new PowerPoint with no file selected. Declaring the Form Show Sub as Public lets another Application(Excel) run it

John Wilson
07-08-2021, 08:34 AM
The code to open the userform needs to be in the open PPT presentation

If the sub is called showform and is in Module1

Excel code woulkd look like


Sub testme()
Dim ppt As Object
Dim strName As String
Set ppt = GetObject(Class:="PowerPoint.Application")
strName = ppt.activepresentation.Name
ppt.Run strName & "!Module1.showform"
End Sub

Jhon90
07-08-2021, 10:05 AM
The code to open the userform needs to be in the open PPT presentation

If the sub is called showform and is in Module1

Excel code woulkd look like


Sub testme()
Dim ppt As Object
Dim strName As String
Set ppt = GetObject(Class:="PowerPoint.Application")
strName = ppt.activepresentation.Name
ppt.Run strName & "!Module1.showform"
End Sub

Thanks Sir. Its working.

Varun Taylor
08-09-2021, 04:13 AM
Since I am an inexperienced microsoft office user, I needed some help with Excel. Specifically, link excel to powerpoint (https://slidepeak.com/blog/excel-linked-presentations) in preparing a presentation. For me, the article on this topic became useful. Everything is very accessible and step by step.