Vladimir Vajda
Posts: 75
Joined: 2011-05-24
|
I have some dictionary of workbooks currently opened in excel. But I have problem with key. I used workbook.FullName for key earlier since this is unique property with which I can identify particular workbook. But when user opens new workbook its name is Book1. And when it save it its name changes to something else and I cannot find it anymore in my dictionary. I cannot use beforeSave event either because user can easily click on cancel button on prompted dialog and cancel saving where beforeSave event is already fired, and also there is no information about new name of workbook being saved. I'm searching for some property (e.g. GUID, ID) which is of primitive type and will uniquely idenfity workbook. Can I use Equals method for this or maybe GetHashCode or something third?
Any suggestion?
best regards,
Vladimir Vajda |
|
Andrei Smolin
Add-in Express team
Posts: 19138
Joined: 2006-05-11
|
Hi Vladimir,
For a new unsaved workbook, your add-in can intercept WorkbookBeforeSave and show the Save/SaveAs dialog e.g. via Excel.Application.GetSaveAsFilename(). And if you use Excel 2010 only, then it provides the WorkbookAfterSave event.
Alternatively, you can add a custom property to the Workbook.CustomDocumentProperties collection (of the Office.DocumentProperties type). This way is simpler. But there's a way to see the property and its value in the Office UI.
Andrei Smolin
Add-in Express Team Leader |
|
Vladimir Vajda
Posts: 75
Joined: 2011-05-24
|
Thanks Adndrei,
I think I'll do it with custom properties. |
|
Andrei Smolin
Add-in Express team
Posts: 19138
Joined: 2006-05-11
|
Good luck!
Andrei Smolin
Add-in Express Team Leader |
|