Click here to Skip to main content
Click here to Skip to main content

View/Modify Office File Properties using OLE

, 22 Jun 2005
Rate this:
Please Sign up or sign in to vote.
This article allows to view/modify the file summary properties.

Sample Image - DSOFileDemo.gif

Introduction

In one of my projects, I wanted to send additional information with file like version history, created by, approved by, etc. when my files are viewed by my users in offline mode (they have downloaded the files from Intranet and read it) without using any external data repository like XML/TXT. So I thought utilizing the summary tab of files and it will not require any external data repository.

As per my application requirement, I just had to work with .DOC, .XLS and .PPT files, so I used the DSO to perform this task.

Using the code

This is a simple code snippet which fetch the file information, and update it once you have modified the information. Here is code which does the core work:

private DSOFile.OleDocumentPropertiesClass myDSOOleDocument = 
    new DSOFile.OleDocumentPropertiesClass();
/***************************************************** 
* Opening file 
* ***************************************************/ 
openFileDialog1.ShowDialog(); 
myDSOOleDocument.Open(openFileDialog1.FileName,false , 
     DSOFile.dsoFileOpenOptions.dsoOptionOpenReadOnlyIfNoWriteAccess); 


/***************************************************** 
* Reading from file through DSO and writing values to form 
* ***************************************************/ 
txtTitle.Text = myDSOOleDocument.SummaryProperties.Title; 
txtSubject.Text = myDSOOleDocument.SummaryProperties.Subject; 
txtAuthor.Text = myDSOOleDocument.SummaryProperties.Author; 
txtCategory.Text = myDSOOleDocument.SummaryProperties.Category; 
txtKeyword.Text = myDSOOleDocument.SummaryProperties.Keywords; 
txtComment.Text = myDSOOleDocument.SummaryProperties.Comments ;


/***************************************************** 
* Reading from form and writing values to File summary through DSO 
* ***************************************************/ 
myDSOOleDocument.SummaryProperties.Title = txtTitle.Text; 
myDSOOleDocument.SummaryProperties.Subject = txtSubject.Text; 
myDSOOleDocument.SummaryProperties.Author = txtAuthor.Text; 
myDSOOleDocument.SummaryProperties.Category = txtCategory.Text; 
myDSOOleDocument.SummaryProperties.Keywords = txtKeyword.Text; 
myDSOOleDocument.SummaryProperties.Comments = txtComment.Text; 
myDSOOleDocument.Save();

Points of Interest

I was able to provide user friendly search without even opening file, just with the help of DSO. This can be a straight forward approach to create small knowledge base too.

History

Initial version added on 23 June, '05.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Vivek Singh - IN
Web Developer
India India
No Biography provided

Comments and Discussions

 
GeneralUsing IPropertyStorage Pinmemberrdkcds16-Feb-10 2:44 
GeneralUnauthorizedAccessException Pinmemberchawkins125-May-07 6:24 
GeneralRe: UnauthorizedAccessException PinmemberVivek Singh - IN25-May-07 15:29 
QuestionWhat about non-office files? Pinmembervaximillian15-Feb-07 8:38 
AnswerRe: What about non-office files? PinmemberVivek Singh - IN18-Feb-07 18:10 
GeneralRe: What about non-office files? Pinmembervaximillian22-Feb-07 23:07 
GeneralRe: What about non-office files? PinmemberS. Calistio28-Jul-07 5:48 
Generalsmall help Pinmembersamasavinirs6-Mar-06 22:43 
GeneralBeware using wrong version of DSOFile.DLL Pinmembergxdata22-Jun-05 22:06 
GeneralRe: Beware using wrong version of DSOFile.DLL PinmemberVivek Singh - IN22-Jun-05 22:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 23 Jun 2005
Article Copyright 2005 by Vivek Singh - IN
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid