Wednesday, September 10, 2008 4:19 PMHi all,
As we know, while we using Microsoft office application, we can easily change the page size and can easily know the current document page size, in other words, the word document can have more than one page size setting.
And now, I want to detect the word document page size (include width and height) with the VSTO component , but I haven’t find any method or property can provide this. Can anyone give some sample codes or give me some suggestions?
Ether C# or VB.NET will be ok, I look forward for you helps. Thanks.
http://lh6.ggpht.com/laiyunqing/SMfy3CwaXkI/AAAAAAAAABE/2OF50uKuw4Q/s640/pagesize.JPG Figure 1. page size in office word 2007 document view
Wednesday, September 10, 2008 4:38 PMModerator
Since page size can vary from section to section, the best thing is to query the PageSetup properties of the Document.Section object. For example, you can loop through all the sections of the document:
Dim doc as Word.Document
Dim sec as Word.Section
Dim pgHeight as Single, pgWidth As Single
Set doc = wdApp.ActiveDocument
For each sec in Document.Sections
pgHeight = sec.PageSetup.PageHeight 'returns height in Points
pgWidth = sec.PageSetup.PageWidth
Wednesday, September 10, 2008 5:13 PMI got it, thank you very much.