Convert C# to Class Library to read Office Doc Properties

Need to read the Office Document Properties from Word, Excel and Powerpoint. Can use the MS code from [url removed, login to view] which works fine as below (I modified it to use an existing doc rather than creating a new one).

However, I'd like it to compile it into a DLL so it can be called by ASP.NET or WinForms in both C# and VB.NET (VS2010). So you need to implement this as a class library and sort out the interface references. I beleive this is possible but I don't have the experience or time to fiddle with that right now - I get the old "oDoc is a field but is used like a type" errors on an initial standalone class. You probably know better!

Task: Convert it to a (still C#) Class Library so I can reference the compiled DLL in another project and query for the Author, Title and Manager of a standard office doc (provided as an input filepath string).

Code to adjust:

using [url removed, login to view];

using Word = [url removed, login to view];

using [url removed, login to view];

namespace FilePropertyChecker


public partial class FormMSApp : Form


public FormMSApp()




private void btnGo_Click(object sender, EventArgs e)


[url removed, login to view] oApp;

Word._Document oDoc;

//object oMissing = [url removed, login to view];

object oDocBuiltInProps;

//object oDocCustomProps;


oApp = new [url removed, login to view]();

oDoc = [url removed, login to view](@"C:\Docs\[url removed, login to view]",

ReadOnly: false, Visible: false);

//[url removed, login to view]();

////Create an instance of Microsoft Word and make it visible.

//oWord = new [url removed, login to view]();

//[url removed, login to view] = true;

////Create a new Document and get the BuiltInDocumentProperties collection.

//oDoc = [url removed, login to view](ref oMissing, ref oMissing, ref oMissing,

// ref oMissing);

oDocBuiltInProps = [url removed, login to view];

Type typeDocBuiltInProps = [url removed, login to view]();

//Get the Author property and display it.

string strIndex = "Author";

string strValue;

object oDocAuthorProp = [url removed, login to view]("Item",

[url removed, login to view] |

[url removed, login to view],

null, oDocBuiltInProps,

new object[] { strIndex });

Type typeDocAuthorProp = [url removed, login to view]();

strValue = [url removed, login to view]("Value",

[url removed, login to view] |

[url removed, login to view],

null, oDocAuthorProp,

new object[] { }).ToString();

[url removed, login to view]("The Author is: " + strValue, "Author");

//close objects...

[url removed, login to view]();




Let me know if it's possible, should only take an hour or two if so - will include this code working in WinForms proj attached to help, see what you think. Thanks, Phil

Have attached a WinForms project with this working code. Have realised that selecting the file will lock it - causing a conflict on the second attempt. That's because it's using Documents.Open - you'll need to be able to read the doc properties without opening, or at least by ensuring correct closure, otherwise it won't work well through a class library (where it will be called from non -user interfaces, ie we don;t want to actually open the doc, just read the properties). Appreciate that may add some time onto this project. Cheers, Phil.

Compétences : .NET, Programmation C#, Architecture Logicielle

en voir plus : word doc class library, convert dll class library, word reference com, what you need to know for programming, what is vb net used for, what is com in vb.net, what is a string in programming, what is application programming interface, what is an object in programming, what is an application programming interface, what is a library in programming, what is a class in programming, vb net winforms, t$c, string standard, string programming, string library in c, string library c, string c programming, standard string, standard programming, standard library c, reflection programming, public programming, programming what is a class

Concernant l'employeur :
( 2 commentaires ) London, United Kingdom

Nº du projet : #1016014

Décerné à:


please check your pmb.

%selectedBids___i_sum_sub_7% %project_currencyDetails_sign_sub_8% GBP en 0 jours
(24 Commentaires)

5 freelance font une offre moyenne de £45 pour ce travail


hi,i can do it for [login to view URL]

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% GBP en 1 jour
(36 Commentaires)

Lets start it.

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% GBP en 2 jours
(45 Commentaires)

please check your PMB

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% GBP en 1 jour
(10 Commentaires)

Hi, please see PMB

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% GBP en 3 jours
(2 Commentaires)