Assemble presentation from current show

  • Thread starter Thread starter Martin Stender
  • Start date Start date
M

Martin Stender

Hi all

I have a weird issue regarding assembling a new presentation from the
current running show.

I have a large presentation that references a ppa, that contains the
code below. There's a button that calls the copySlideToPresentation
sub.


The problem is, that although I specifically create the new
presentation at the 'newPath' location, it gets saved in my 'My
Documents' folder ... weird.

Here it is:

Dim thePresentation as Presentation
Public Const thePath As String = "C:\templates"
Public Const newPath As String = "C:\presentations"

Sub copySlideToTemplate()
Dim TemplateFileName As String
Dim pres As Presentation
Dim thiswin As SlideShowWindow
Dim found As Boolean
Dim i, j As Integer
Dim Item As Variant
Dim newname As String

Set thiswin = ActivePresentation.SlideShowWindow

If thePresentation Is Nothing Then
'check if we have to create a new pres.
For Each pres In Presentations
' Checking for Custom Document Properties

For Each Item In pres.CustomDocumentProperties
If Item.Name = "Something to identify these by" Then
Set thePresentation = pres
End If
Next
Next

If thePresentation Is Nothing Then
' No presentation - create new"
newName = InputBox("New presentation name", "Please type
the presentation name")
'get new name

FileCopy thePath & "\Template.pot", newPath & "\" & newName
& ".ppt"

TemplateFileName = newPath & "\" & newName & ".ppt"

Set thePresentation = Presentations.Open(TemplateFileName,
msoFalse, msoTrue, msoTrue)

thePresentation.CustomDocumentProperties.Add
Name:="Something to identify these by", LinkToContent:=False,
Type:=msoPropertyTypeBoolean, Value:=True
thePresentation.Slides(1).Layout = ppLayoutTitleOnly
thePresentation.Slides(1).Shapes(1).TextFrame.TextRange =
newname

thePresentation.Save
End If
End If

SlideShowWindows(1).View.Slide.Copy
thePresentation.Slides.Paste
thePresentation.Save
thiswin.Activate

End Sub


Any idea why the path of 'thePresentation' gets set to the 'My
Documents' folder?

Best regards
Martin
 
Hi all

I have a weird issue regarding assembling a new presentation from the
current running show.

I have a large presentation that references a ppa, that contains the
code below. There's a button that calls the copySlideToPresentation
sub.

The problem is, that although I specifically create the new
presentation at the 'newPath' location, it gets saved in my 'My
Documents' folder ... weird.

Here it is:

Dim thePresentation as Presentation
Public Const thePath As String = "C:\templates"
Public Const newPath As String = "C:\presentations"

Sub copySlideToTemplate()
Dim TemplateFileName As String
Dim pres As Presentation
Dim thiswin As SlideShowWindow
Dim found As Boolean
Dim i, j As Integer
Dim Item As Variant
Dim newname As String

Set thiswin = ActivePresentation.SlideShowWindow

If thePresentation Is Nothing Then
'check if we have to create a new pres.
For Each pres In Presentations
' Checking for Custom Document Properties

For Each Item In pres.CustomDocumentProperties
If Item.Name = "Something to identify these by" Then
Set thePresentation = pres
End If
Next
Next

If thePresentation Is Nothing Then
' No presentation - create new"
newName = InputBox("New presentation name", "Please type
the presentation name")
'get new name

FileCopy thePath & "\Template.pot", newPath & "\" & newName
& ".ppt"

TemplateFileName = newPath & "\" & newName & ".ppt"

Set thePresentation = Presentations.Open(TemplateFileName,
msoFalse, msoTrue, msoTrue)

thePresentation.CustomDocumentProperties.Add
Name:="Something to identify these by", LinkToContent:=False,
Type:=msoPropertyTypeBoolean, Value:=True
thePresentation.Slides(1).Layout = ppLayoutTitleOnly
thePresentation.Slides(1).Shapes(1).TextFrame.TextRange =
newname

Depending on how you open a presentation, PPT may or may not set the current
directory to the presentation file's directory. A .Save will save to the
current direction, I'm fairly sure, so you probably need to force the issue:
instead of this:
thePresentation.Save

try

thePresentation.SaveAs(TemplateFileName)

Or before the .Save explicitly set the current drive directory to where you
want the save to take place.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top