c# - Using Late-Binding to Automate Word is throwing a MissingMemberException -
i trying access information running microsoft word application using following code..
object appclass = marshal.getactiveobject("word.application"); object documents = appclass.gettype().getproperty("documents"); object count = documents.gettype().invokemember("count", bindingflags.getproperty, null, documents, null);
when run code tells me that count not found , has thrown missingmemberexception.
can tell me doing wrong?
you didn't reference documents object, getproperty returns propertyinfo. fix:
object appclass = marshal.getactiveobject("word.application"); object documents = appclass.gettype().invokemember("documents", bindingflags.getproperty, null, appclass, null); object count = documents.gettype().invokemember("count", bindingflags.getproperty, null, documents, null);
adding reference microsoft.office.word.interop can make lot less painful.
Comments
Post a Comment