Hello,
I'm not sure what I'm doing wrong. I get no error notification when I try to overwrite the file which is open in different app. For example Acrobat.
Like the error is not triggered.
code.jpg
Thank you in advance
Hello,
I'm not sure what I'm doing wrong. I get no error notification when I try to overwrite the file which is open in different app. For example Acrobat.
Like the error is not triggered.
code.jpg
Thank you in advance
Should post code as text between CODE tags so readers can copy/paste it - not image. Can edit your post.
Have you step debugged?
How to attach file: How to upload your attachments (vbaexpress.com) To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Hi, you are right. Sorry. Pasted an image.
I have addedNow it asks if I'm sure that I want to overwrite the file but there is no warning box that it could not be done as file is currently in use.Application.DisplayAlerts = True
Tbh I can use nativebut I would like to have more custom dialogApplication.CommandBars.ExecuteMso("FileSaveAs")
Here is what I have now:
Sub CommandButton3_Click() Dim dlgSaveAs As FileDialog On Error GoTo ErrorHandler Application.DisplayAlerts = True If Application.Presentations.Count = 0 Then Call MsgBox("Please open presentation file before save", vbExclamation, "Test") Exit Sub End If Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs) dlgSaveAs.Title = "Save PDF" dlgSaveAs.ButtonName = "Save PDF" dlgSaveAs.FilterIndex = 4 With dlgSaveAs If .Show Then .Execute Call MsgBox("PDF was saved successfully", vbInformation, "Test") Else Call MsgBox("PDF was not saved", vbInformation, "Test") End If End With NormalExit: Exit Sub ErrorHandler: MsgBox "Error" Resume NormalExit: End Sub
Try
Sub test() Dim dlgSaveAs As FileDialog Dim strPath As String On Error GoTo ErrorHandler If Application.Presentations.Count = 0 Then Call MsgBox("Please open presentation file before save", vbExclamation, "Test") Exit Sub End If Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs) dlgSaveAs.Title = "Save PDF" dlgSaveAs.ButtonName = "Save PDF" dlgSaveAs.FilterIndex = 4 With dlgSaveAs If .Show Then call ActivePresentation.SaveAs (.SelectedItems(1), ppSaveAsPDF) Call MsgBox("PDF was saved successfully", vbInformation, "Test") Else Call MsgBox("PDF was not saved", vbInformation, "Test") End If End With NormalExit: Exit Sub ErrorHandler: MsgBox "Error" Resume NormalExit End Sub
Last edited by John Wilson; 12-20-2022 at 08:31 AM.
John Wilson
Microsoft PowerPoint MVP
Amazing Free PowerPoint Tutorials
http://www.pptalchemy.co.uk/powerpoi...tutorials.html
Thank you!
I had a feeling this .Excecute was a problem.
I added path checking in ErrorHandler MsgBox so now it reflects native SaveAs behaviour.