6
Answers

How to get word/excel files' properties,eg. count of pages, in C#?

Photo of Administrator

Administrator

22y
5.4k
1
I need to know Microsoft Office files' properties:pages count. How do I do?

Answers (6)

1
Photo of Administrator
Tech Writer 2.2k 1.6m 22y
my email is sinotitan@hotmail.com
1
Photo of Administrator
Tech Writer 2.2k 1.6m 22y
Could you give me a example codes paragraph? i need to know how to define "fileName","newTemplate",etc. Thanks!
1
Photo of Administrator
Tech Writer 2.2k 1.6m 22y
I am creating word document and printing the forms in windows application. I need some help in setting the security level of WORD to low to run the macros. I know how to do it manually. I need some help in doing this progrmatically. I would like to know how to set Application.AutomationSecurity=msoAutomationSecurityLow in Word Programatically in C# windows application. MY CODE IS BELOW..... // Instantiating Word WordApp = new Word.ApplicationClass(); // Create a new Document, by calling the Add function in the Documents collection Word.Document aDoc = WordApp.Documents.Add(ref fileName, ref newTemplate, ref docType,ref isVisible); aDoc.Activate(); WordApp.Selection.InlineShapes.AddPicture( CurrentFileName, ref LinkToFile, ref SaveWithDocument,ref missing); WordApp.Selection.InsertBreak(ref oPageBreak); WordApp.PrintOut(ref Background, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); // Closing the Doc WordApp.Documents.Close(ref missing,ref missing,ref missing); I appreciate your help in this regard. Any knowledgebase articles also will be helpful too! I did get some info but couldn't find the .AutomationSecurity in my word object or in word documentto set. Please thro' some light on this. the articles I found are http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnword2k2/html/odc_wdoverride.asp http://www.microsoft.com/office/ork/xp/two/admc04.htm
1
Photo of Administrator
Tech Writer 2.2k 1.6m 22y
Hi, I am creating word document and printing the forms in windows application. I need some help in stting the security level of WORD to low to run the macros. I know how to do it manually. I need some help in doing this progrmatically. I would like to know how to set Application.AutomationSecurity=msoAutomationSecurityLow in Word Programatically in C# windows application. MY CODE IS BELOW..... // Instantiating Word WordApp = new Word.ApplicationClass(); // Create a new Document, by calling the Add function in the Documents collection Word.Document aDoc = WordApp.Documents.Add(ref fileName, ref newTemplate, ref docType,ref isVisible); aDoc.Activate(); WordApp.Selection.InlineShapes.AddPicture( CurrentFileName, ref LinkToFile, ref SaveWithDocument,ref missing); WordApp.Selection.InsertBreak(ref oPageBreak); WordApp.PrintOut(ref Background, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); // Closing the Doc WordApp.Documents.Close(ref missing,ref missing,ref missing); I appreciate your help in this regard Thanks, Skrosuri.
1
Photo of Administrator
Tech Writer 2.2k 1.6m 22y
I know how. First you have to create an object (word or excel) using interop. For instance you would create your word OLE object and for example purposes we'll name it objWdDoc. To access the properties like number of pages etc. You have to use the BuiltInDocumentProperties property. Example: objWdDoc.BuiltInDocumentProperties(14).value this will return the number of pages in the document. 14 is a const value that you would have to look up. Basically the BuiltInDocumentProperties property gives you access to everything you would see on the dialog that pops up when (in word) you click File, Properties. You can get a list of the constants by going into Visualbasic macro editor in word or excel, looking for the properties, and in the description it shows the numeric value. Hope it helps. B4cchus
1
Photo of Administrator
Tech Writer 2.2k 1.6m 22y
Why not no one know how to get word file's page in C#?