Jump to content

Recommended Posts

Posted (edited)

Hi All,

I understand that the SaveAs method saves the file in the specified location that is passed as parameter. But this method is not working as expected for me. May be my understanding is wrong.

In PowerPoint 2007 I created a add-in. In this i added a application event an class. If the addin open I do want tthe user to save the file in .pptx format. So I added the following code in the before save event.

	 Private sub AppEvent_BeforeSave(ByVal Pres as Presentation,Cancel as Boolean)
Dim fd As FileDialog

' To check whether the documet is saved or not
If InStr(1, Pres.Name, ".") = 0 Then
If Pres.Saved = False Then
IsSavedAs = False
Else
IsSavedAs = True
End If
End If

If isNitroReport(Pres) Then

If IsSavedAs = False Then
Do

Set fd = Application.FileDialog(msoFileDialogSaveAs)
iSaveFile = 7
fd.FilterIndex = 3
fd.Show

On Error Resume Next
strFileName = ""
strFileName = fd.SelectedItems(1)

If Right(strFileName, 5) = ".pptx" Then
iSaveFile = MsgBox("This supports only PowerPoint 97-2003 Presentation (*.ppt) format.Do you want to save with *.ppt format?", vbYesNo, MSGBOX_TITLE)

ElseIf iSaveFile <> 7 Or strFileName <> "" Then
iSaveFile = 0
End If

If iSaveFile = 0 Then

ElseIf iSaveFile = 7 Then
IsSavedAs = False
Cancel = True
Exit Sub
End If

Loop Until Right(strFileName, 5) <> ".pptx"

'SaveAsUI = True

If strFileName <> "False" Then
IsSavedAs = True
Pres.Saved = True
Pres.SaveAs FileName:=strFileName ',' FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
Pres.Save

End If
Cancel = True
IsSavedAs = True
End If
End If
Exit Sub
err:
IsSavedAs = False
Cancel = True
Call AppEvent_PresentationBeforeSave(ActivePresentation, True)
End Sub

When the SaveAs executed the file name is changed but not the file path. And also the file is not saved at the specified location. When I click on Save the save as dialog box is again is displayed. I do not know why this is happing.

Edited by abiram01

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...