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
Steve Rindsberg - 07 Jun 2006 16:31 GMT
> Hi all
>
[quoted text clipped - 58 lines]
> 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.
> End If
> End If
[quoted text clipped - 11 lines]
> Best regards
> Martin
-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================