Word Automation on Custom Properies

csharp Hāora, India
  • 12 years ago
    Hi,
    I´m trying to make word automation on document custom properties(for a given 
    property name change the value)
     
    I put this code together:
    Type Prop = Type.GetTypeFromProgID("Word.CustopParoperties");
                System.Object obj = Activator.CreateInstance(Prop);
                
                Microsoft.Office.Interop.Word.CustomProperties CustomProp = obj 
    as Microsoft.Office.Interop.Word.CustomProperties;
                foreach (Microsoft.Office.Interop.Word.CustomProperty property 
    in CustomProp)
                {   if (property.Name == valfind) property.Value = valreplace;   }
     
    and I get this error
     
    Exception Details: System.ArgumentNullException: Value cannot be null.
    Parameter name: type
     
    Source Error: 
     
     
    Line 53:             
    Line 54:             Type Prop = 
    Type.GetTypeFromProgID("Word.CustopParoperties");
    Line 55:             System.Object obj = Activator.CreateInstance(Prop);
    Line 56:             
    Line 57:             Microsoft.Office.Interop.Word.CustomProperties 
    CustomProp = obj as Microsoft.Office.Interop.Word.CustomProperties;
     
     
    As I understand I dont have the ProgID right
    any ideas what should be there
    I´m quite new to this and running out of hope
     
    Thanks
     

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Linux is only free if your time has no value” - Jamie Zawinski