index > Visual Studio Tools for Office > How to correct use of Pages object (Microsoft.Interop.Word)

How to correct use of Pages object (Microsoft.Interop.Word)


?еоб?одимо найти ?а??о?ожение и ?азме? ???мо??о?ьни?о?, об??ат??аю?и? ?аждое ??о?о и ?а?тин?? ? до??менте Word (??и заданн?? ?о?мати?о?ании и ?а?амет?а? ?т?ани??).

??таю?ь это ?де?ать ?е?ез ??ой?т?о Rectangles об?е?та Pages (_Document.ActiveWindow.ActivePane.Pages) ??ед?ю?им об?азом:


object missing = Type.Missing;
object fileName = @"c:\1.rtf";
object dontConfirmConversions = false;
object openReadWrite = true;
object nonVisible = false;

Word._Application wapp = new Microsoft.Office.Interop.Word.Application();
Word._Document doc = wapp.Documents.Open( ref fileName, ref dontConfirmConversions,
ref openReadWrite, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref nonVisible, ref missing, ref missing,
ref missing, ref missing );

Word.Pages pages = doc.ActiveWindow.ActivePane.Pages;

using ( StreamWriter sw = new StreamWriter( "TestFile.txt" ) ) {
foreach ( Word.Page p in pages ) {
Word.Rectangles rects = p.Rectangles;
foreach ( Word.Rectangle r in rects ) {
sw.WriteLine( " Width:" + r.Width + " Height: " + r.Height );
}
}
}

?тот ?од до?жен зане?ти ?азме?? ??е? об?ам??ю?и? ???мо??о?ьни?о? ? ?ай? TestFile.txt.

Что он, ? ??ин?и?е, и де?ает :)
?о ?о???ает?? то?ь?о одна за?и?ь, ??и?ем д?? ?юбо?о ?ай?а (на??име?, Width:312 Height: 728).

Я та? ?онимаю, ?то это ?азме? об?ам??ю?е?о ???мо??о?ьни?а д?? ??е? данн?? ? до??менте :)

?то ?о?о?о, ?едь е?ть ??ой?т?о Lines об?е?та Rectangles, ?ото?ое, ? ??ин?и?е, можно б??о б? и??о?ьзо?ать та?:

Вме?то ?и??а:
foreach ( Word.Rectangle r in rects ) {
sw.WriteLine( " Width:" + r.Width + " Height: " + r.Height );
}
??дем иметь та?ой:
foreach ( Word.Rectangle r in rects ) {
foreach ( Word.Line line in r.Lines ) {
foreach ( Word.Rectangle lr in line.Rectangles ) {
sw.WriteLine( " Width:" + r.Width + " Height: " + r.Height );
}
sw.WriteLine();
}
}

?дна?о ??и из??е?ении ??ой?т?а line.Rectangles ???етаBт и???ю?ение.

Что ?о?о?ет?ете де?ать ? та?ой ?ит?а?ии?
Я ?онимаю, ?то ?о??о? до?о?ьно ?е?ьезн?й и т?еб?ет дей?т?ите?ьно?о ??о?е??иона?изма, но ? за?е? ? т??и?, ?оэтом? о?ень б?д? ?ад ?омо?и.




Regards, Oleg
Oleg Lola

Hi Oleg

These are English-speaking forums, devoted to the VSTO technology. General Interop questions aren't handled here. If you can formulate your question in English, please try again - in a newsgroup specifically for Office object model automation:

http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.office.developer.automation&lang=en&cr=US

Cindy Meister
reply 2

You can use google to search for other answers

 

More Articles

·connectivity issues outlook 2003
·VB.net equivalents of VBA Macro code
·Optional Parameters and overloading in a C# Managed Automation Ad...
·Unit testing a .NET app hosted within Office
·Unable to access "Page Brak View"
·What Kind of things can I do with VSTO?
·AddIn-Debugging doesn't work anymore?!?!
·VSTO 2005 Beta2 FAQ
·Install Outlook Add-in from C# Code....
·WebBrowser Control Hosting Word: How do I programmatically enable...
Welcome to Bokebb   New Update   Joins the collection  
 

New Articles

·Migrating an VBA Excel solution to VSTO
·Filling a ListObject is really slow.
·Word COM addin stops when application.Se
·Manual Page breaks vs automatic page bre
·How to program add-in for Outlook withou
·Parse Control on Action Pane by VSTO
·VSTO install balks at VS 2005 beta
·login to MS Exchange 2003
·Mail item icons
·Moving text within a document without us
·Treeview webpart in Sharepoint 2003
·Accessing Sheets from a new class
·Word Objects Within XmlNode
·VSTO August CTP COM Exception
·VSTO templates missing in August CTP?

Hot Articles

·How to figure out what my problem is...
·Creating Contacts in Outlook
·Can I use outlook 2003 PIAs for Outlook
·How do I get a "Quiet" install
·Handling New Email event or open/reply/f
·Proxies for Java Class
·Install with vsts team site july
·Action Panel, MS Word and database access
·Excel Fixed horizonal and vertical panes
·Why I can not open remote Office documen
·C++ AddIns 4 MS-Word
·Outlook 2003 LoadBehavior
·How to Populate the value Dynamically in
·Custom Selection
·Print to upper tray in Access

Recommend Articles

·Can't deploy VSTO 2005 Project
·Measure the width of a string contained
·Unable to access "Page Brak View&qu
·ListOject Displaying updates on Excel ha
·add sender to blocked sender list did no
·Question re the CRM Integration Add-In S
·Save data Within Excel through VB?
·How can I map the fields of infopath for
·where can i find vsto apis for word proj
·XML and Word 2002
·I created a addin for office and its not
·HELP: On MSDN, Office 2003 Key Un-Known?
·rounding chart corners in Excel
·Can a WebBrowser control be used in an E
·VSTO project does not appear in "VS