Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel XP and WorkbookBeforeSave

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Excel XP and WorkbookBeforeSave

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.

"Dave McL." wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel XP and WorkbookBeforeSave

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

"Patrick Molloy" wrote:

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.

"Dave McL." wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
WorkbookBeforeSave Problem Steve Excel Discussion (Misc queries) 2 November 1st 09 10:01 AM
Handling WorkbookBeforeClose and WorkbookBeforeSave Tom Ogilvy Excel Programming 0 September 19th 03 06:27 PM


All times are GMT +1. The time now is 04:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"