D
Daniel
Hello,
i have a problem with the word automation from c#. First,
i want to mention, that i don't have any dependencies from
word in my c#-project, i want to use the system.reflection
model to handle the automation.
So, i'm using the following code to create a new word
document:
---Code---
object objApplication;
object objDocuments;
object objDocument;
objApplication = System.Activator.CreateInstance(
Type.GetTypeFromProgID("Word.Application"));
objDocuments = objApplication.GetType().InvokeMember
("Documents", BindingFlags.Default |
BindingFlags.GetProperty, null, objApplication , null);
objDocument = objDocuments.GetType().InvokeMember("Add",
BindingFlags.Default | BindingFlags.InvokeMethod, null,
objDocuments, null);
---End of Code---
This works fine. But several properties cannot be accessed
like that. For example, when i try to get the
properties "BuiltInDocumentProperties"
or "CustomDocumentProperties" like the "Documents"-
property in the example above, i get an exception with the
text "Unknown name.".
Am i doing anything wrong? Is it possible to get all
properties with the system.reflection model?
Thanks in advance for your help.
Regards,
Daniel
i have a problem with the word automation from c#. First,
i want to mention, that i don't have any dependencies from
word in my c#-project, i want to use the system.reflection
model to handle the automation.
So, i'm using the following code to create a new word
document:
---Code---
object objApplication;
object objDocuments;
object objDocument;
objApplication = System.Activator.CreateInstance(
Type.GetTypeFromProgID("Word.Application"));
objDocuments = objApplication.GetType().InvokeMember
("Documents", BindingFlags.Default |
BindingFlags.GetProperty, null, objApplication , null);
objDocument = objDocuments.GetType().InvokeMember("Add",
BindingFlags.Default | BindingFlags.InvokeMethod, null,
objDocuments, null);
---End of Code---
This works fine. But several properties cannot be accessed
like that. For example, when i try to get the
properties "BuiltInDocumentProperties"
or "CustomDocumentProperties" like the "Documents"-
property in the example above, i get an exception with the
text "Unknown name.".
Am i doing anything wrong? Is it possible to get all
properties with the system.reflection model?
Thanks in advance for your help.
Regards,
Daniel