Excel XP and WorkbookBeforeSave

D

Dave McL.

The following code snippet works fine in Excel 2003, but XP behaviour is
different.
In Excel XP I get prompted to save the file twice.
Any ideas - TIA Dave

Private Sub m_ThisApplication_WorkbookBeforeSave(ByVal Wb As
Microsoft.Office.Interop.Excel.Workbook, ByVal SaveAsUI As Boolean, ByRef
Cancel As Boolean) Handles m_ThisApplication.WorkbookBeforeSave

If SaveAsUI Then
sBeforeSaveFilename = Wb.Name
m_ThisApplication.EnableEvents = False
m_ThisApplication.Dialogs(xlDialogSaveAs).Show()

' prevent a second save
m_ThisApplication.EnableEvents = True
Cancel = True
End If
Wb = Nothing
 
P

Patrick Molloy

it is not the enable events method that you turn off, it's the display alerts
method that you turn off. Alternatively, set the workbooks SAVED property to
TRUE.
 
D

Dave McL.

By leaving EnableEvents on the event "WorkbookBeforeSave" will get fired
twice, creating the same problem.
Application.ActiveWorkbook.Saved is set to true by
"m_ThisApplication.Dialogs(xlDialogSaveAs).Show()".
Setting display alerts to false had no effect.

Cheers
Dave
 

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

Top