• Home
  • Product-Life
  • PDF
  • Excel
  • Word
  • My Music Box
It's a long road...

HTML-to-RTF Pro DLL .Net

A standalone .Net class library for C#, VB.Net, J# and ColdFusuion developers. 

Learn More

C# Word – Set Word Properties

3/19/2012

0 Comments

 
C# Set Word Properties
Why Set Word Properties

Microsoft Office Word is the most popular and easiest tool for users designing and creating different articles. In Microsoft Office Word/Excel/PowerPoint(version 2007 or later), users are allowed to view or edit document properties easily while work on document content by using the Document Information Panel which displays at the top of your document in your Office program. The properties of a Word document usually includes details such as title, subject, keywords, created time, author name, company, category, etc. If we want to search some file, we can search based on its properties. And all these properties can be easily modified at any time.

How to Use C# Set Word Properties

This article is introducing you how to use C# set Word properties by using Spire.Doc which is a professional and powerful .NET/Silverlight Word component. Download Spire.Doc, make sure Spire.Doc and Visual Studio are correctly installed on system. Follow the simple guide below to set Word properties with C#/VB.NET.

Step 1 Create a Project
Create a C#/VB.NET project in your visual studio. Add Spire.Doc.dll as reference. The default setting of Spire.Doc.dll is placed under "C:\Program Files\e-iceblue\Spire.Doc\Bin”. Select assembly Spire.Doc.dll and click OK to add it to the project.

using System;
using Spire.Doc;
using Spire.Doc.Fields;
using Spire.Doc.Documents;

namespace TableWidth
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
        }
    }
}

Step 2 Load Word File
Load Excel file which we want to set properties for.

            Document document = new Document();                        
           document.LoadFromFile(@"D:\sample.doc");

Step 3 C# Set Word Properties
Assign string value for workbook.DocumentProperties.author/title etc. By using Spire.Doc, we can set many Excel properties such as author, title, key words, category, company, etc.

document.BuiltinDocumentProperties.Title = "Document Demo Document";            document.BuiltinDocumentProperties.Subject = "demo";            
document.BuiltinDocumentProperties.Author = "James";            
document.BuiltinDocumentProperties.Company = "e-iceblue";           
document.BuiltinDocumentProperties.Manager = "Jakson";           
document.BuiltinDocumentProperties.Category = "Doc Demos";            document.BuiltinDocumentProperties.Keywords = "Document, Property, Demo";            document.BuiltinDocumentProperties.Comments = "This document is just a Demo";

Step 4 Save and Preview
The following code can help us save and preview the output Word file.

//Save doc file.
document.SaveToFile("Sample.doc", FileFormat.Doc);


Effective Screenshot:
Picture

More about Spire.Doc

Spire.Doc is a MS Word component which enables user to perform a wide range of Word document processing tasks directly, such as generate, read, write and modify Word document for .NET and Silverlight. It supports C#, VB.NET, ASP.NET, ASP.NET MVC and Silverlight. Click to learn more…

0 Comments



Leave a Reply.

    Categories

    全部
    Add Header/Footer
    Add Watermark
    C# Add Images
    C# Word Hyperlinks
    C# Word Table
    C# Word Text Color
    Encrypt Word
    Extract Word Image
    Html To Image
    Html To Word
    Insert Page Break
    Insert Word Borders
    Merge Word Documents
    Set Word Properties
    Word Footnote
    Word To Epub
    Word To Html
    Word To Pdf

    RSS Feed

    Recommend Blog:


    Blu-ray/DVD Backup
    Office Tricks
    No.1 Software Pick

Powered by
✕