Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

obtaining the print dialog using reflection

3 views
Skip to first unread message

tonegawa

unread,
Mar 8, 2010, 2:00:01 PM3/8/10
to
I'm using word automation, and I need to correct the old code, in order to
use just the reflection, and not the direct reference to the office libraries
from visual studio.

The old code had:

varDlg =
varWord.Application.Dialogs[Microsoft.Office.Interop.Word.WdWordDialog.wdDialogFilePrint]

I don't know how to invoke the [] operator using reflection.

(also Microsoft.Office.Interop.Word.WdWordDialog.wdDialogFilePrint is not an
int, but an enum type)

tonegawa

unread,
Mar 8, 2010, 3:31:01 PM3/8/10
to
problem solved!!!

These things are called indexed Properties

if you can index a property with [], this property has its own property call
"Item" by default. You can specify the index in the second argument of the
GetValue() method


This is the correct code:

PropertyInfo pi =
(varWord.GetType().Assembly.GetType("Microsoft.Office.Interop.Word.Dialogs")).GetProperty("Item");
varDlg = pi.GetValue(objDialogEnum, new Object[] {
objDialogEnumId });

0 new messages