Hi,
I want to be be to move down a document. In vb script I use selection.movedoen(n,n). How do I do this with ASPOSE metod please
Hi there,
Thanks for your inquiry. It would be great if you please share some more detail about your query what exact you want to achieve by using Aspose.Words.
Please note that Aspose.Words for .NET is a class library that enables your applications to perform a great range of document processing tasks. Aspose.Words supports DOC, DOCX, RTF, HTML, OpenDocument, PDF, XPS, EPUB and other formats. With Aspose.Words you can generate, modify, convert, render and print documents without utilizing Microsoft Word®. For more information, please go through the documentation below:
https://docs.aspose.com/words/net/
Moreover, the DocumentBuilder has an internal cursor that you can navigate to a different location in a document using various DocumentBuilder.MoveToXXX methods such as DocumentBuilder.MoveToDocumentStart and DocumentBuilder.MoveToDocumentEnd. You can move to a node by using MoveTo method. Please also read all method of DocumentBuilder.MoveToXXX.
Hi,
I am currently converting a VB script that inserts details into the header and footer of the active Word document to use ASPOSE as a dll. I use the ASPOSE Moveto functions to go to the first page , then the header followed by the footer. This works fine but once inside the header I need to be able to move doen to a certain line to insert details and also be able to move to the right. Currently I use the Word function Selection.Movedown and Selection.Moveright. Looking at the MoverTo function I cant see how you define that you want to move to a line and not a book mark/paragraph/header/footer . Basically I want to be able to goto a page or a line on a page which is supported by MS Word via the Selection methods
Hi there,
Thanks for your inquiry.
First
of all, please note that Aspose.Words is quite different from the
Microsoft Word’s Object Model in that it represents the document as a tree of objects
more like an XML DOM tree. If you worked with any XML DOM library you
will find it is easy to understand and work with Aspose.Words. When you
load a Word document into Aspose.Words, it builds its DOM and all
document elements and formatting are simply loaded into memory. Please
read the following articles for more information on DOM:
https://docs.aspose.com/words/net/aspose-words-document-object-model/
https://docs.aspose.com/words/net/logical-levels-of-nodes-in-a-document/
Secondly, Please note that MS Word document is flow document and does not contain any information about its layout into lines and pages. Therefore, technically there is no “Page” and “Line” concept in Word document.
Aspose.Words uses our own Rendering Engine to layout documents into pages and lines. Please check using the DocumentLayoutHelper sample from the offline samples pack. This sample demonstrates how to easily work with the layout elements of a document and access the pages, lines, rows, spans etc.
Hope this helps you. Please let us know if you have any more queries.
Morning,
Many thanks for your help. I have had a read of the items you suggested and still not certain how to replicate the following code with ASPOSE
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.MoveDown Unit:= wdLine, Count:=2
Selection.TypeText Text:="Branding Details"
Selection.MoveRight Unit:=wdcell
Selection.TypeText Text:="Company Details"
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Selection.GoTo what:=wdGoTopage, Which:= wdGoToNext, Name:="2"
wdSeekCurrentPageHeader = 9
wdLine = 5
wdCell = 12
wdSeekMainDocument = 0
wdGoTopage = 1
wdGoToNext = 2
This is the code generated by recoding a macro in word. We use this type of code/functions to insert branding details in to a document after the merge has been performed.
Any ideas how I can do this with Aspose.Words please.
Hi there,
Thanks for your inquiry. DocumentBuilder is a powerful class that is associated with a Document and allows dynamic document building from scratch or the addition of new elements to an existing document.
When you need to place some data into a header or footer, you should move there first using DocumentBuilder.MoveToHeaderFooter. The method accepts a HeaderFooterType enumeration value that identifies the type of header or footer to where the cursor should be moved. Please read following documentation link for your kind reference.
https://docs.aspose.com/words/net/navigation-with-cursor/
Hope this helps you. If you still face problem, please share your input and expected output documents. Please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate, how you want your final Word output be generated like. We will then provide you more information on this along with code.
Following code example shows how to use DocumentBuilder.MoveToXXX method.
// Create a blank document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Specify that we want headers and footers different for first, even and odd pages.
builder.PageSetup.DifferentFirstPageHeaderFooter = true;
builder.PageSetup.OddAndEvenPagesHeaderFooter = true;
// Create the headers.
builder.MoveToHeaderFooter(HeaderFooterType.HeaderFirst);
builder.Write("Header First");
builder.MoveToHeaderFooter(HeaderFooterType.HeaderEven);
builder.Write("Header Even");
builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
builder.Write("Header Odd");
// Create three pages in the document.
builder.MoveToSection(0);
builder.Writeln("Page1");
builder.InsertBreak(BreakType.PageBreak);
builder.Writeln("Page2");
builder.InsertBreak(BreakType.PageBreak);
builder.Writeln("Page3");
doc.Save(MyDir + "DocumentBuilder.HeadersAndFooters Out.doc");