Đang Thực Hiện

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()

{

InitializeComponent();

}

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;

//OPEN EXISTING DOC...

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.

Kỹ năng: .NET, Lập trình C#, Kiến trúc phần mềm

Xem thêm: 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

Về Bên Thuê:
( 2 nhận xét ) London, United Kingdom

Mã Dự Án: #1016014

Đã trao cho:

crypted

please check your pmb.

£30 GBP trong 0 ngày
(24 Đánh Giá)
5.0

5 freelancer đang chào giá trung bình £45 cho công việc này

forrestwang

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

£50 GBP trong 1 ngày
(36 Đánh Giá)
6.6
djain01

Lets start it.

£45 GBP trong 2 ngày
(45 Đánh Giá)
5.1
mastersoft1

please check your PMB

£50 GBP trong 1 ngày
(10 Đánh Giá)
3.7
Mxdmg

Hi, please see PMB

£49 GBP trong 3 ngày
(2 Đánh Giá)
2.4