|
-
Apr 3rd, 2009, 09:36 AM
#1
Thread Starter
Lively Member
[RESOLVED] PPT template open via Word
Hey all,
I've created a PowerPoint template (.pot) file for my clients to use if they need to create a corporate presentation. Here we use MS Word as a main conduit to all our word (.dot) templates and alike, I'm trying to add my new template with the others on a form in Word but to no success, I'm created the below code but it keep throwing a wobbly "RT Error 91 - ob variable or with block variable not set"
Any Help would be greatly appreciated
Code:
Sub cmd_showpowerpoint_Click()
Dim ppt As Object
Dim MyappID As String
ppt.Presentations.Open FileName:="k:\zprecedents\dls.pot", Untitled:=msoTrue
MyappID = Shell("C:\Program Files\Microsoft Office\Office\POWERPNT.EXE", 1) 'Run Microsoft Powerpoint
FileSystem.ChDir "K:\"
Set ppt = CreateObject("powerpoint.application")
Set ppt = Nothing
End Sub
-
Apr 3rd, 2009, 10:14 AM
#2
Re: PPT template open via Word
The problem with your code is you are trying to use the object before creating it....
Here is a basic way, you can open a Powerpoint file using late binding...
vb Code:
Sub cmd_showpowerpoint_Click()
Dim ApPPT As Object, prsnPPT As Object
On Error Resume Next
'~~> Check if PowerPoint if already Open
Set ApPPT = GetObject(, "Powerpoint.application")
If ApPPT Is Nothing Then
'~~> If no instance of PowerPoint is found then open one
Set ApPPT = CreateObject("Powerpoint.application")
End If
On Error GoTo 0
'~~> Display PowerPoint
ApPPT.Visible = True
'~~> Open File
Set prsnPPT = ApPPT.Presentations.Open("c:\sid.pot")
End Sub
hope this helps...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Apr 3rd, 2009, 11:14 AM
#3
Thread Starter
Lively Member
Re: PPT template open via Word
Yeah Sorry, I posted my code in the wrong order do'h! the original is below.
I tried your code which works well, but it opens it up directly into the .pot file, I need the template to open as a new .ppt which I thought my code would.
I suppose all I'd need to do is add to yours is at the open file bit?
Code:
Sub cmd_showpowerpoint_Click()
MyappID = Shell("C:\Program Files\Microsoft Office\Office\POWERPNT.EXE", 1) 'Run Microsoft Powerpoint
ppt.Presentations.Open FileName:="k:\zprecedents\dls.pot", Untitled:=msoTrue
FileSystem.ChDir "K:\"
Set ppt = CreateObject("powerpoint.application")
Set ppt = Nothing
End Sub
-
Apr 3rd, 2009, 12:24 PM
#4
Re: PPT template open via Word
I need the template to open as a new .ppt which I thought my code would.
Oh Ok, Is this what you Want? Remember to Set Reference to the Microsoft Powerpoint Object library
vb Code:
'~~> IMPORTANT NOTE: Set Reference to the Microsoft Powerpoint Object library Sub cmd_showpowerpoint_Click() Dim ApPPT As PowerPoint.Application Dim prsnPPT As PowerPoint.Presentation Dim slidePPT As PowerPoint.Slide Set ApPPT = CreateObject("Powerpoint.Application") '~~> Make it visible. ApPPT.Visible = True '~~> Add a new presentation. Set prsnPPT = ApPPT.Presentations.Add(msoTrue) '~~> Add a new slide. Set slidePPT = prsnPPT.Slides.Add(1, ppLayoutText) '~~> Apply Presentation prsnPPT.ApplyTemplate Filename:="k:\zprecedents\dls.pot" End Sub
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Apr 6th, 2009, 04:43 AM
#5
Thread Starter
Lively Member
Re: PPT template open via Word
Works brilliantly! many thanks again!
-
Apr 6th, 2009, 04:50 AM
#6
Re: [RESOLVED] PPT template open via Word
You are welcome
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Jun 25th, 2009, 06:10 AM
#7
Thread Starter
Lively Member
Re: [RESOLVED] PPT template open via Word
Bump!
Great code for pp + word users
Last edited by Kubull; Jun 25th, 2009 at 09:04 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|