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:
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:
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…