Hello,

This is Gokul Rangarajan. I need a suggestion or code in JavaScript which reads the MS Word document page settings and number of pages. I know how to open and read a MS Word document, but i couldn't able to get page properties. Some one please help me with this.

Thank you,
Gokul Rangarajan

Hi, this is gokul rangarajan. I just found solution for my proble,

var w=new ActiveXObject('Word.Application'); --creare MS word obj.
w.Documents.Open("C:\\ABSTRACT.doc"); -- open a doc..
obj=w.visible=false; --- set visible false
obj.Content; --- to get content in MS word doc..
w.ActiveDocument.ComputeStatistics(2); -- Get number of pages
w.ActiveDocument.ActiveWindow.Panes(1).Pages.Item(1).Width; -get width in pixels..
w.ActiveDocument.ActiveWindow.Panes(1).Pages.Item(1).Height; -get height in pixels..
w.ActiveDocument.PageSetup.TopMargin --get Margin top in pixels
w.ActiveDocument.PageSetup.LeftMargin --get Margin left in pixels
w.ActiveDocument.PageSetup.BottomMargin --get Margin bottom in pixels
w.ActiveDocument.PageSetup.RightMargin --get Margin right in pixels
w.ActiveDocument.PrintOut(); //Print given document


Note: 72 pixel = 1 inches.

Thank you,:cool:
Gokul Rangarajan

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.