nwein
Posts: 577
Joined: 2011-03-28
|
Is it possible to add my own file extension (e.g. .adx) to the save as dialog in Excel (2010)? |
|
Eugene Astafiev
Guest
|
|
nwein
Posts: 577
Joined: 2011-03-28
|
Thanks for pointing me to the right direction.
I would like to display my modified msoFileDialogSaveAs and msoFileDialogOpen (i.e. with the additional filter) when user clicks the open and/or save as options. Do I need to intercept those events? (either from shortcut or from menu click)
Addendum:
While your sample for the open file dilaog works:
Microsoft.Office.Core.FileDialog fd = ExcelApp.get_FileDialog(MsoFileDialogType.msoFileDialogOpen);
FileDialogFilters filters = fd.Filters;
filters.Add("Eugene Astafiev", "*.zip", 1);
if (fd.Show() == -1)
{
// here you can load the document into Word
MessageBox.Show(fd.SelectedItems.Item(1));
}
The same doesn't work with msoFileDialogSaveAs (throws a Member not found exception).
Any idea how to tackle this?
I understand it's not entirely Add-in express related but still thought I could harness your Excel brains for the task :) |
|
Eugene Astafiev
Guest
|
|
nwein
Posts: 577
Joined: 2011-03-28
|
I saw that MSDN as well, was hoping there's another way of doing it....
That leads me to ask - can I provide my own save as dialog, mimicking Excel's save as (with the addition of my own filter)? Is there anything special about Excel's save as dialog that is different than a regular save file dialog?
If so then I guess I must intercept any attempt to save with my own dialog. Right?
Funny you mention the release of COM objects (although this code was just a sample, not meant to be production quality), as this is http://www.add-in-express.com/forum/read.php?FID=1&TID=6370... :) |
|
Eugene Astafiev
Guest
|
Hi Nir,
Of course, you can use the System.Windows.Forms.SaveFileDialog component for displaying your own dialog.
You are right: the sample code which I published on the forum doesn't include any ReleaseCOMObject statements due to the fact that it was pasted to illustrate how the task can be implemented. But in the production code you should always release underlying COM objects to avoid issues described in the http://www.add-in-express.com/creating-addins-blog/2008/10/30/releasing-office-objects-net/ article. That is why I always pay special attention to this. |
|