Link to home
Start Free TrialLog in
Avatar of jackjohnson44
jackjohnson44

asked on

c# how do I get who created a word doc?

I want to find out who created a word doc?

        private void GetFileInformation(Document Doc)
        {
                 //how do I get created by
Avatar of margajet24
margajet24
Flag of Singapore image

Avatar of jackjohnson44
jackjohnson44

ASKER

I already have the document being passed in, isn't there a way to do it without making another instance of word?  This will take way too long.  Isn't there a way to get it from the doc?
please see this..
private void GetFileInformation(Document Doc)
        {
            object BuiltInProps;
 
            BuiltInProps = Doc.BuiltInDocumentProperties;
 
            Type TypeBuiltingProp = BuiltInProps.GetType();
 
            string Prop = "Author";
            string AuthorName;
            object AuthorProp = TypeBuiltingProp.InvokeMember("item", BindingFlags.Default | BindingFlags.GetProperty, null, BuiltInProps, new Object[] { Prop });
            Type TypeAuthorProp = AuthorProp.GetType();
 
            AuthorName = TypeAuthorProp.InvokeMember("Value", BindingFlags.Default | BindingFlags.GetProperty, null, AuthorProp, new Object[] { }).ToString();
 
            Console.WriteLine("{0}", AuthorName);
        }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of margajet24
margajet24
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial