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();
openFileDialog1.ShowDialog();
myDSOOleDocument.Open(openFileDialog1.FileName,false ,
DSOFile.dsoFileOpenOptions.dsoOptionOpenReadOnlyIfNoWriteAccess);
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 ;
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.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.