Hi there

I have never used Aspose.Words before, and I'm now trying to get to grips with it. In my current project I have to merge some data into a ".dot" file - there are bookmarks in the .dot file for which I have to set the text - this seems easy enough.

Another thing I have to do is some page-setup. I have values for margins etc, which I have to set for the whole document. How do I do this? It appears that a document consists of sections, and each section has a pagesetup property - do I have to do page-setup in each section in the document, or is it possible just to do one, which is then global for the entire document?

Thanks, Peter


Hi Peter,

If your template has more than one section then you need to iterate through Document.Sections collection and set the desired page setup for each section. There is no global page setup settings in MS Word document structure and in our API as well. Hope this answers your question. If you have other questions plase don't hesitate to post them here - I will be glad to assist you with whatever I can.

Best regards,


OK, thanks. I have no idea about the format for Word documents either - so that's another hurdle I have to get over. Is it correct that in the Aspose.Words API there are several ways of getting the same data? For example, it appears that

document.Range.Bookmarks gets all the bookmarks for the document, as if you had iterated through all the sections getting their bookmarks individually.

it also appears that Section.ChildNodes returns a NodesCollection for the Section which contains a Body, which is the same as Section.Body. Likewise for HeadersFooters?




Yes, that is true. You can use different means for accessing the same objects. In our object model we have tried to follow the .NET guidelines and the model itself is very much resembling .NET implementation of XML DOM. Please check our programmer's guide which is available online in Wiki format and also as a local HTML Help (.chm) file included in distribution package. It has several nice articles introducing and explaining Word document structure and how it is reflected in our object model.

To get a hands-on experience I would recommend to run our DocumentExplorer source code demo project which can be found in C:\Program Files\Aspose\Aspose.Words\Demos\DocumentExplorer directory after installation. It gives a nice visual representation of the document structure and gives an idea how it is interpreted by Aspose.Words.

Best regards,


OK, thanks. I have been browsing the API docs and help - but with all new things it's hard to know precisely where to begin (escpecially with the pressure of a project deadline looming).

Where can I find info (or maybe you can give the answers) to these questions:

(1) in my document template (.dot file) I have areas which appear to be called "frames" by Microsoft Word. How can I access these entities via Aspose.Words in order to alter there properties, eg. horizontal & vertical positions.

(2) is it possible to set one top margin for the document's "first page" and another top margin for all "other pages"? (There seems to be the possibility for setting "FirstPageTray" and "OtherPagesTray", but I can't find a corresponding "first page margin" and "other pages margin").

Thanks again,



"Frame" has different meaning in MS Word 97-2000 and MS Word 2002-2003. In the former the so called "text frame" was some kind of a textbox. And in the latter frames represent multidocument sets with framed representation like in HTML pages. The modern multidocument frame sets are not supported by Aspose.Words. The text frames are supported. If you will attach the sample template with text frame I will post a sample code on how it can be handled in the latest version of our library.

As far as I know there is no separate setting in MS Word for top margin of the document's "first page" and "other pages". It can be done however by putting the first page in one section and other pages to next section, i.e. inserting a section break in the end of first page. Then you can set the top margin differently for the section containing first page and all other sections.

Asking just out of curiosity - why do you want to make page setup formatting using Aspose.Words. Isn't it much simplier to update the templates according to your needs using MS Word?

Best regards,


Hello again

thank you for the offer. Attached is the file "A_Flet.doc" (actually my file is called "" but I had to change the extension to .doc in order to upload it).

I am working on a web-application where users log in to perform "case handling" tasks. One of the things they can do is generate a word file which they can print and send as a letter to a client.

The word file is to contain some information the user enters and some information which is generated by the application. The users belong to a "user-group", and each user-group has some specific formatting requirements which the application reads and sets in the word document. Margins and foot text and so on.

The word-document is to be based on a template (.dot) file which the customer supplies. The template file contains bookmarks for which the application is to set the text. Some of the text for the bookmarks comes from the user, some text is generated by the application according to the user's user-group. (The .dot file is from a "legacy application" which the customer is in the process of replacing).

For example, there is a bookmark called "AfdInfo", which means "branch information". Here, the application finds information relevant to the user-group, and sets the bookmark text to an address (from-company, telephone number, etc). But this bookmark is also contained in a "frame", and each user-group has specific requirements to the horizontal and vertical position of the frame. I need to be able to set these values.

Likewise for bookmarks called "Modtager" (recipient), "Bundtekst" (footer text), "Vedrørende" (concerning)... and so on.

I also have to set document-wide page-setup, like margins for top, left, right, and bottom. This I think I have found out by iterating over all the Sections and using PageSetup. The only thing is that "top margin" is supposed to be different on the "first page" and "other pages".

Sorry for the long description, and many thanks,



Unfortunately the text frames properties editing is not available in our public API. I don't think we are going to expose it soon because it does not fit very well in our current obejct model. You can try substituting text frames with textboxes as a workaround. BTW inserting text frames is not supported in MS Word beginning with MS Word 2002. That is a sign that MS considers text frames obsolete although text frames which are already in the document are supported for backwards compatibility.

Hope that helps,


OK, thanks for your response. My problem then is that the templates I am using are supplied by the customer, and are to be used "as is". So I will need to find another way around their requirements of setting the horizontal and vertical positions of the various "text frames".




Hello yet again!

Now the customer has agreed to let us change the template - in order to make it easier for us. But I would like to hear your recommendations for a word entity that I can use to hold a bookmark (for which I can set the text) and for which I can set the horizontal and vertical positions. Would a "text box" be ok? And is it compatible with Word97 as this is what the customer has installed on their client machines.

Thanks again,



Yes, textboxes are supported in Word97. To create textbox follow this steps:

In MS Word's main menu click Insert | Textbox. The canvas will show up with a large invitation "Create your drawing here". Don't. Put cross-shaped cursor outside the canvas area and draw texbox by dragging. Remove borders of the textbox via context menu.

Now you have a textbox that looks exactly like the text frame but is actually much better. All subsequent textboxes can be created by copying-pasting of the first. After you make the new template please attach it here. I will then compose and post a sample code for handling the textboxes inside the template.

Best regards,