Click here to Skip to main content
15,908,931 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

does someone know, how i can use the OpenFileDialog from MS-Office in a .Net application.

Thanks in advance


edit:
i found a solution. but i'm not happy with it because i have to make a isntance of a office app (here i took access).

Microsoft.Office.Interop.Access.ApplicationClass app = new Microsoft.Office.Interop.Access.ApplicationClass();
Microsoft.Office.Core.FileDialog ofd = app.get_FileDialog(Microsoft.Office.Core.MsoFileDialogType.msoFileDialogOpen);
ofd.Show();
;

Any ideas about .get_FileDialog? Maybe there's a COM lib which i could use directly instead of let the Office app call the constructor?

edit2:
this is not possible with the normal Office.Interop (see answers below). But maybe Microsoft used an AcitveX-Object or something for the dialog (because it's reused in every Office-App). IF so i could reuse it too.

Maybe someone know were the "places" are located in the registry?

Thanks in advance for any help

mathias
Posted
Updated 25-Mar-10 0:45am
v4

1 solution

No you must do it this way:

http://msdn.microsoft.com/en-us/library/microsoft.office.core.filedialog_members(office.11).aspx[^]

The FileDialog doesn't have a ctor, and the dialog must have a [Office] host application create it.

Personally, I think you are barking up the wrong tree, and should be implementing your own dialog, as what you are doing is tying yourself to Office.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900