1

I am working on a C# COM add-in specifically targeting Excel XP. I need to display my own 'Save As' dialog rather than the normal Excel dialog.

I tried handling the applicationObject.WorkbookBeforeSave and ActiveWorkbook.BeforeSave events and setting the 'ref bool Cancel' parameter to true, but Excel still pops up the 'Save As' dialog. Saving the Workbook in these event handlers doesn't make any difference.

If I handle the Click event on the Save button then the dialog doesn't pop up, but that doesn't take of when the user presses Ctrl-S to save.

Any ideas?

Thanks.

AndrewS
  • 3,450
  • 1
  • 21
  • 26
  • What customisation of the dialog are you looking to achieve? – David Heffernan Sep 23 '11 at 10:45
  • I want to display my own dialog to save documents to a records management system and not display the Excel dialog unless the user chooses to save locally. – AndrewS Sep 23 '11 at 11:54
  • Why don't you register your record management system as a namespace extension and then Excel can find it with its dialog. – David Heffernan Sep 23 '11 at 12:06
  • I need to do much more than just save the file to a particular folder which requires writing code against the record management system SDK and displaying associated UI. I'll need to do something similar when opening files, but I guess I can use the same solution as saving files if its possible. – AndrewS Sep 24 '11 at 08:20
  • None of that happens inside the file chooser dialog. – David Heffernan Sep 24 '11 at 08:21
  • Which is why I don't want to display the Excel 'Save As' dialog at all - I want to display my own dialogs and open/save files using the Excel Application object. – AndrewS Sep 24 '11 at 10:50

1 Answers1

1

I have found a solution. It seems there is a problem with trying to cancel some events through C# in Excel XP. I found that using the code in this thread solves my problem: http://www.tech-archive.net/Archive/Excel/microsoft.public.excel.programming/2009-10/msg04732.html

Edit: The issue causing my problem and workaround is detailed here: http://support.microsoft.com/kb/830519

AndrewS
  • 3,450
  • 1
  • 21
  • 26