Office的OpenFileDialog [英] OpenFileDialog from Office
问题描述
有人知道,我如何在.Net应用程序中使用MS-Office中的OpenFileDialog.
在此先感谢
我找到了解决方案.但我对此不满意,因为我不得不放弃一个办公应用程序的位置(在这里我可以访问).
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();
;
关于.get_FileDialog有什么想法吗?也许有一个COM库,我可以直接使用它,而不是让Office应用程序调用构造函数?
edit2:
对于普通的Office.Interop,这是不可能的(请参见下面的答案).但是也许 Microsoft为对话框使用了AcitveX-Object或其他东西(因为它已在每个Office-App中重复使用).如果是这样,我也可以重用它.
也许有人知道注册表中的地方"吗?
预先感谢您的任何帮助
mathias
;
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
推荐答案
否,您必须这样做:
http://msdn.microsoft.com/en-us /library/microsoft.office.core.filedialog_members(office.11).aspx [ FileDialog 没有ctor,并且对话框必须具有[Office]宿主应用程序才能创建它.
就个人而言,我认为您正在树错树,应该实现自己的对话框,因为您所做的就是将自己与Office联系在一起.
No you must do it this way:
http://msdn.microsoft.com/en-us/library/microsoft.office.core.filedialog_members(office.11).aspx[^]
TheFileDialog
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.
这篇关于Office的OpenFileDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!