E
Evan Stone
Hi,
How would one go about accessing the Application.NormalTemplate.Saved
property in Word via C# and LATE bound?
I'm currently getting the infamous "do you want to save Normal.dot" error on
certain systems from the following code (it seems to be from fresh
installations of Word, since some default settings are being saved to
Normal.dot on the first run), and I'd like to be able to set the
NormalTemplate.Saved property to true to inhibit the dialog in that
situation...
// Code Snippet Begin ----------------------
Type WordType = Type.GetTypeFromProgID("Word.Application");
//Create instance of word
wordObject = Activator.CreateInstance(WordType);
if (wordObject != null)
{
parameter[0] = true;
//get the Version property
version = (string) WordType.InvokeMember("Version",
BindingFlags.DeclaredOnly | BindingFlags.Public |
BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.GetProperty, null,
wordObject, null);
// close the application
WordType.InvokeMember("Quit",
BindingFlags.DeclaredOnly |
BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.InvokeMethod, null,
wordObject, null);
}
wordObject = null;
// Code Snippet End ----------------------
My question is how do I get at that property if I'm trying to work late
bound? Do I need to get the NormalTemplate object first then call an
InvokeMember on it to get the value of its Saved property?
Thanks!
evan k. stone | software engineer
How would one go about accessing the Application.NormalTemplate.Saved
property in Word via C# and LATE bound?
I'm currently getting the infamous "do you want to save Normal.dot" error on
certain systems from the following code (it seems to be from fresh
installations of Word, since some default settings are being saved to
Normal.dot on the first run), and I'd like to be able to set the
NormalTemplate.Saved property to true to inhibit the dialog in that
situation...
// Code Snippet Begin ----------------------
Type WordType = Type.GetTypeFromProgID("Word.Application");
//Create instance of word
wordObject = Activator.CreateInstance(WordType);
if (wordObject != null)
{
parameter[0] = true;
//get the Version property
version = (string) WordType.InvokeMember("Version",
BindingFlags.DeclaredOnly | BindingFlags.Public |
BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.GetProperty, null,
wordObject, null);
// close the application
WordType.InvokeMember("Quit",
BindingFlags.DeclaredOnly |
BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.InvokeMethod, null,
wordObject, null);
}
wordObject = null;
// Code Snippet End ----------------------
My question is how do I get at that property if I'm trying to work late
bound? Do I need to get the NormalTemplate object first then call an
InvokeMember on it to get the value of its Saved property?
Thanks!
evan k. stone | software engineer