Adding section to active page

Hi
I´m trying to create a very simple javascript for adding new section to active page. So far I have made following code:
var myDoc = app.activeDocument;
var numero = app.activeWindow.activePage.name;
var numero2 = numero -1;
myDoc.sections.add(myDoc.pages[numero2]);
It basically works as it should, whren I double-click some page thumbnail in pages panel, that page will become active... and if I run the script at that point it usually adds section to active page pretty nicely....
However, if I use that script with Configurator 2.0 and create a custom panel, with Add a section button (where I have attached that same javascript) InDesign starts to throw me some weird alert:
If I answer yes, script will work as it should, but I would like to make it work so that users won´t get that alert at all....
If I run that scrpt from Scripts panel, it works without alerts...
Another thing I have tried to figure out is how to create some kind of error handler that would stop the script if active page already has a section start, now script generates a javascript error in those cases.... it would be more classy if simply nothing happened....
Any help appreciated.... thanks

Thanks guys...=) but no luck here....
And I noticed something quite weird. This script is meant to use with single pages, but when I accidentally used it with facing pages spreads, I got that same alert + script changed the way page numbers are marked below thumbs:
It replaced 10-11 with 10,11
I also tried
try {
var myDoc = app.documents[0];
var numero = app.documents[0].layoutWindows[0].activePage.name;
var numero2 = numero -1;
myDoc.sections.add(myDoc.pages[numero2]);
} catch (e)
{  $.writeln("Error "+e.message+" at line "+e.line);}
But I still have that same alert.... When I run that code in Extend Script ToolKit, I got following javascrip console message:
Error undefined is not an object at line 2
Result: undefined

Similar Messages

  • How to change the header and footer in the Section Breaks Next Page using OpenXML?

    I have a word document file in which I added a Section Break of Next Page, now I want to change the header and footer of that page.
    Scenario of example, I have a doc file which has four pages with headers and footers and added fifth page in the section break next page, I want to change the header and footer of the fifth page only. This is achievable manually by deselecting the Link to Previous
    button in the Word Application but I don't know how to change it using XML?
    My code that adds the new page in the section breaks is:
    class Program
    static void Main(string[] args)
    string path = @"C:\Riyaz\sample.docx";
    string strtxt = "Hello This is done by programmatically";
    OpenAndAddTextToWordDocument(path,strtxt);
    public static void OpenAndAddTextToWordDocument(string filepath, string txt)
    using (DocX document = DocX.Load(@"C:\Riyaz\sample.docx"))
    document.InsertSectionPageBreak();
    Paragraph p1 = document.InsertParagraph();
    p1.Append("This is new section");
    document.Save();
    Please help.

    Here is the sample for your reference:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using DocumentFormat.OpenXml;
    using DocumentFormat.OpenXml.Packaging;
    using DocumentFormat.OpenXml.Wordprocessing;
    namespace WordAddNewFooterHeader
    class Program
    static void Main(string[] args)
    string path = @"E:\Document\TestHeaderandfooter-Copy.docx";
    string strtxt = "OpenXML SDK";
    OpenAndAddTextToWordDocument(path, strtxt);
    public static void OpenAndAddTextToWordDocument(string filepath, string txt)
    // Open a WordprocessingDocument for editing using the filepath.
    WordprocessingDocument wordprocessingDocument = WordprocessingDocument.Open(filepath, true);
    MainDocumentPart part = wordprocessingDocument.MainDocumentPart;
    Body body = part.Document.Body;
    //create a new footer Id=rIdf2
    FooterPart footerPart2 = part.AddNewPart<FooterPart>("rIdf2");
    GenerateFooterPartContent(footerPart2);
    //create a new header Id=rIdh2
    HeaderPart headerPart2 = part.AddNewPart<HeaderPart>("rIdh2");
    GenerateHeaderPartContent(headerPart2);
    //replace the attribute of SectionProperties to add new footer and header
    SectionProperties lxml = body.GetFirstChild<SectionProperties>();
    lxml.GetFirstChild<HeaderReference>().Remove();
    lxml.GetFirstChild<FooterReference>().Remove();
    HeaderReference headerReference1 = new HeaderReference() { Type = HeaderFooterValues.Default, Id = "rIdh2" };
    FooterReference footerReference1 = new FooterReference() { Type = HeaderFooterValues.Default, Id = "rIdf2" };
    lxml.Append(headerReference1);
    lxml.Append(footerReference1);
    //add the correlation of last Paragraph
    OpenXmlElement oxl = body.ChildElements.GetItem(body.ChildElements.Count - 2);
    ParagraphProperties paragraphProperties1 = new ParagraphProperties();
    SectionProperties sectionProperties1 = new SectionProperties() { RsidR = oxl.GetAttribute("rsidR", oxl.NamespaceUri).Value };
    HeaderReference headerReference2 = new HeaderReference() { Type = HeaderFooterValues.Default, Id = part.GetIdOfPart(part.HeaderParts.FirstOrDefault()) };
    FooterReference footerReference2 = new FooterReference() { Type = HeaderFooterValues.Default, Id = part.GetIdOfPart(part.FooterParts.FirstOrDefault()) };
    PageSize pageSize1 = new PageSize() { Width = (UInt32Value)12240U, Height = (UInt32Value)15840U };
    PageMargin pageMargin1 = new PageMargin() { Top = 1440, Right = (UInt32Value)1440U, Bottom = 1440, Left = (UInt32Value)1440U, Header = (UInt32Value)720U, Footer = (UInt32Value)720U, Gutter = (UInt32Value)0U };
    Columns columns1 = new Columns() { Space = "720" };
    DocGrid docGrid1 = new DocGrid() { LinePitch = 360 };
    sectionProperties1.Append(headerReference2);
    sectionProperties1.Append(footerReference2);
    sectionProperties1.Append(pageSize1);
    sectionProperties1.Append(pageMargin1);
    sectionProperties1.Append(columns1);
    sectionProperties1.Append(docGrid1);
    paragraphProperties1.Append(sectionProperties1);
    oxl.InsertAt<ParagraphProperties>(paragraphProperties1, 0);
    body.InsertBefore<Paragraph>(GenerateParagraph(txt, oxl.GetAttribute("rsidRDefault", oxl.NamespaceUri).Value), body.GetFirstChild<SectionProperties>());
    part.Document.Save();
    wordprocessingDocument.Close();
    //Generate new Paragraph
    public static Paragraph GenerateParagraph(string text, string rsidR)
    Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = rsidR };
    ParagraphProperties paragraphProperties1 = new ParagraphProperties();
    Tabs tabs1 = new Tabs();
    TabStop tabStop1 = new TabStop() { Val = TabStopValues.Left, Position = 5583 };
    tabs1.Append(tabStop1);
    paragraphProperties1.Append(tabs1);
    Run run1 = new Run();
    Text text1 = new Text();
    text1.Text = text;
    run1.Append(text1);
    Run run2 = new Run();
    TabChar tabChar1 = new TabChar();
    run2.Append(tabChar1);
    paragraph1.Append(paragraphProperties1);
    paragraph1.Append(run1);
    paragraph1.Append(run2);
    return paragraph1;
    static void GenerateHeaderPartContent(HeaderPart hpart)
    Header header1 = new Header();
    Paragraph paragraph1 = new Paragraph();
    ParagraphProperties paragraphProperties1 = new ParagraphProperties();
    ParagraphStyleId paragraphStyleId1 = new ParagraphStyleId() { Val = "Header" };
    paragraphProperties1.Append(paragraphStyleId1);
    Run run1 = new Run();
    Text text1 = new Text();
    text1.Text = "";
    run1.Append(text1);
    paragraph1.Append(paragraphProperties1);
    paragraph1.Append(run1);
    header1.Append(paragraph1);
    hpart.Header = header1;
    static void GenerateFooterPartContent(FooterPart fpart)
    Footer footer1 = new Footer();
    Paragraph paragraph1 = new Paragraph();
    ParagraphProperties paragraphProperties1 = new ParagraphProperties();
    ParagraphStyleId paragraphStyleId1 = new ParagraphStyleId() { Val = "Footer" };
    paragraphProperties1.Append(paragraphStyleId1);
    Run run1 = new Run();
    Text text1 = new Text();
    text1.Text = "";
    run1.Append(text1);
    paragraph1.Append(paragraphProperties1);
    paragraph1.Append(run1);
    footer1.Append(paragraph1);
    fpart.Footer = footer1;
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Adding a template style page in Pages 5

    Can anyone help me please?
    I have upgraded to Pages 5.0 and not only are there far fewer interesting templates for me to start working from (I am looking particularly in the Newsletters section) but I am also having a problem adding template styled pages to a new project.
    Previously I simply clicked on Insert > Pages in the menu and then selected the layout. I can't seem to find how to do this in 5.0 - all I can do is create a blank section.
    I'm sure I must be missing something really obvious but I can't figure out what it is!
    Regards, Peter
    PS is there any way to upgrade to Pages 5.0 but not lose the decent (interesting) templates? I'm a school teacher and the kids love having interesting templates to start with - these new ones are terrible!

    The lack of page/section styles was one of the first features I noticed missing in Pages 5.0. This is really disappointing for me as I've created a number of my own document templates and have made extensive use of page/section styles.
    On one hand I can understand why Apple may have removed this feature. It is rather an anomaly among its peers. Microsoft Word does not use page/section styles and to some users it could be a bit of a confusing  feature in Pages. I know for me it was somewhat confusing at first. I was used to the MS Word way of doing things and I was wondering how these section style templates differed from me just setting my own section style. But then I figured out that it is like a slide template in Keynote. It is simply a template and can be used as a shortcut to setup a new document section in a standard style. Since figuring out how to use the page/section styles, it has been awesome and has been one of the key reasons I like Pages better than Word and why I switched completely from Word to Pages.
    For now, I guess I will have to figure out how to work without it which will basically mean that I will have to go back to the old manual method of just copying and pasting section styles. It will take longer to add new sections with identical styles to a document and will be more buggy. It is likely that I will not always get it exactly correctly which will result in consistency issues in my documents. As well, the inability to copy and paste whole pages/sections from the page thumbnails will make this process take even longer and be even more buggy. But ultimately it is doable.
    I can only hope that the page/section templates is a feature that Apple will bring back very soon. I wish someone from Apple would at least let us know if this feature will be making its way back in or if it is gone for good. Accordingly, we could move on or plan for its return.

  • Navigation menu active page color not behaving as it should

    I created an unordered list for the mainnav links. I use the following lines in the code:
    <li><a href="../index.html" class="thispage">Home</a></li>
            <li><a href="#">Events</a></li>
            <li><a href="#">Music</a></li>
            <li><a href="#">Agenda</a></li>
            <li><a href="../Pages/artists.html">Artists</a></li>
    The Home button shows the color for 'active', but if I go to the artists page it first shows the hover color, then the page opens but does not show the active color.... I.o.w. the Home button stays on active though it is not active.
    Please see the effect on my testsite: www.adrianrooymans.nl

    armona22 wrote:
    I'm sorry, but I tried that already, and it does not solve the problem. If I do that I get TWO active pages, but clicking anywhere on the artists page makes the blue color go away, except for the Home button.... I could temporarily put that on the testserver so that you could see what happens (unless you beleive me).
    You will get two active menu items unless the class is removed from the links that you don't want it on.
    If you look at the example page code in the 'completed' folder of the Bayside Beat tutorial you will see on the 'index' page the class has been added to the 'index' link:
    <nav id="mainnav">
          <ul>
            <li><a href="index.html" class="thispage">Home</a></li>
            <li><a href="sightseeing.html">Sightseeing</a></li>
            <li><a href="#">Eating Out</a></li>
            <li><a href="#">What's On</a></li>
            <li><a href="#">Where to Stay</a></li>
          </ul>
        </nav>
    Whilst on the 'sightseeing' page the class has been moved to the 'sightseeing' link:
    <nav id="mainnav">
            <ul>
                <li><a href="index.html">Home</a></li>
                <li><a href="sightseeing.html" class="thispage">Sightseeing</a></li>
                <li><a href="#">Eating Out</a></li>
                <li><a href="#">What's On</a></li>
                <li><a href="#">Where to Stay</a></li>
            </ul>
        </nav>

  • How can I show an active page on menu?

    I am working in DW CS3 and using a Spry menu and want to be able to show the active page on the menu. Have looked at previous discussions but am still very confused. New to DW and not very code editing proficient. Please help.

    Place the following in the HEAD section of your document
    <script src="SpryAssets/SpryDOMUtils.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript">
    function InitPage(){
    Spry.$$('#MenuBar1 li').forEach(function(node){
         var a=node.getElementsByTagName("a")[0]; // finds all a elements inside the li, but we only want the first so [0]
         if(a.href == window.location){
              Spry.Utils.addClassName(node,"activeMenuItem");
    Spry.Utils.addLoadListener(InitPage);
    </script>
    <style type="text/css">
    .activeMenuItem {
         background: #F00;
         font-weight: bold;
    </style>
    and make sure that SpryDOMUtils.js is in your SpryAssets folder.
    Ben

  • Output a JPG / PNG of a section of a page

    Any help would be appreciated with the following.
    I have an online preview system where a user can upload an in design document and fill out web form controls (text boxes, check boxes, etc) to generate a quick preview of the output of an in design document as a JPG.
    What I want to do next is when a user enters into a form field I want in design server to output a section of the page as a high DPI JPG to show to the user what section of the page the user is editing.
    I know the pages and the bounds on which the custom field is on. Is there a way to create a new document or a new page and say output just this section in a higher DPI to output a high res JPG?
    Dustin

    Hi,
    I suggest a workflow like this:
    1. dialog ask user for number of page and section coordinates (lets say left-up corner, width and height) in active doc;
    2. the surrounding area size can be set there as well;
    3. this dialog let user to choose some output properties including output file path;
    4. entire page is exported to a temp file;
    5. new doc and empty rectangle with proper size is created;
    6. rectangle's stroke is as wide as surrinding area is set;
    7. rectangle's stroke transparency is set to some value (another dialog entry?);
    8. page as an image is loaded there and moved to proper position;
    9. rectangle is exported as JPG or PNG (CS6+) according to dialog choices.
    I should take 1-2 hours. How worth is it for you?
    Jarek

  • How do I break up a Section? (in Pages)

    I have a Section that Pages has created as I have built a up a document (not quite sure why it's done this, but that's one of the mysteries of Pages).
    As I've been moving individual pages around within the Section, it's been adding extra pages within the section.
    In theory, I should be able to delete these by clearing them of content, but what happens in practice is that as I delete the last bit of content from such a page it deletes the whole Section. (Which I then have to recover by using Undo).
    I think the best way to deal with this is to break up the whole Section into individual pages, but netiehr Help, nor Apple, nor the iWork '09 book has any suggestions on how best to do this.
    Any clues?
    Thanks
    Andrew Curry

    I think what you are seeking is "Section Break" (Pages > Insert > Section Break).
    This thread tells you a bit more:
    https://discussions.apple.com/message/15148723#15148723

  • Ibooks author, section text vs pages

    What is the difference between added "Section Text" to a section under a chaper and adding "Pages?"

    I think RTL sliding is not possible, and yes, IBA has same RTL bugs as Pages.  Plus the iBookstore Publisher User Guide says that the iBookstore does not support Arabic.
    But perhaps someone has found a way around these issues....

  • Create TOC on active page

    Hello Scripters,
    I am trying to create my toc on the fifth page of my document.
    At the moment the script is running I am adding the fifth page and scripting like this:
    function toc() {
        var myTOCStyle = myDocument.tocStyles.itemByName("TOC_normal");
        var myTocPage = myDocument.pages.add(LocationOptions.AT_END);
        var myBounds = myGetBounds(myDocument, myTocPage);
        var myX1 = myBounds[1];
        var myY1 = myBounds[0];
        var myStory = myDocument.createTOC(myTOCStyle, true, undefined, [myX1, myY1]);
    the script creates the toc on page 4 with bounds of page 5 (right page).
    doesn't the script always creates the toc at the active page? this should be page 5, as it was just added?
    I do not want to move the toc-frame after creating it, I want the script to place the toc on the correct page, what's wrong with my code?
    Thanks a lot in advance for any answer,
    franzi_ska

    From this point of view you're right, I have to find a workaround to avoid the problem (but I still want to knwo what's the problem about my script).
    I tried your suggestion:
    var myStory = myDocument.createTOC(myTOCStyle, true, undefined, [myX1, myY1]);
    var myFrame = myStory.textFrames[0];
    myFrame.move(myTocPage);
    Now the problem lies in the 2nd line (Object is undefinied).
    I think var myFrame = myStory[0].textFrames[0]; is right as the toc returns an array of story.
    So the problem still excists...
    In any case: Thank you very much for helping me!

  • View enable and disable dynamically in Guided activity page

    Hi Team,
    I have created a GP and it contains 2 views inside a Guided activity page.
    Here the issue is I need to show both the views but I should be able to disable any one of the view dynamically.
    Note:
    As I said earlier it should not disappear. It should just be disabled.
    I have tried using do config determination with different configurations but it is making the views disappear.
    Especially the first view...!
    Please help.
    Thanks,
    Mahesh Pusala

    Hello Mahesh,
    You can check below methods in _IMPL class of the over view page.
    DETACH_STATIC_OVW_VIEWS: to hide any view
    REATTACH_STATIC_OVW_VIEWS : to display the view
    for hiding the view delete the view entry from the internal table " rt_return" in the "DETACH_STATIC_OVW_VIEWS" method.
    to show a view add the view name including component name to the "rt_return" table in "REATTACH_STATIC_OVW_VIEWS" method.
    hope this helps you.
    Br,
    Navn

  • HELP --- Error while adding Portlets to the Page. (WWC-44012)

    Hi all,
    I have a pl/sql portlet. It compiles fine and shows up perfectly in portlet repository. But when i add this to the page, I get following error
    Error while adding Portlets to the Page. (WWC-44012)
    An unexpected error occurred: User-Defined Exception (WWC-43000)
    An unexpected error occurred: User-Defined Exception (WWC-43000)
    An unexpected error occurred: User-Defined Exception (WWC-51004)
    (WWC-00000)
    I checked the portlet specification file (.pks) and body file (.pkb) for any mistakes but they seems fine.
    Does anyone know what can cause this error?
    Any pointers in this regards will be highly appreciated.
    Thanks!!!
    Rajesh

    Rajesh,
    Could you provide some more details about your code? I will try to look into possible causes of the error. One thing you may try is subscribing to the Knowledge Exchange on http://portalcenter.oracle.com. Then you could post your code in your community folder and everyone would be able to test it out.
    Of course, this means you must be willing to share your code with everyone.
    James

  • Using iWork 09 Pages I need the first six pages of a document to not be counted as page numbers. I need the seventh page to be numbered as page one. I already know to have a section break between pages 6 and 7 and to use inspector "start at." Not working

    In the book I'm formatting, the first page is the title page, the second page is the copyright page, the third through fifth pages are the table of contents, the sixth page is blank, then the text (which I want to number as page one) is the introduction. I have section breaks between the title page, the copyright page, the table of contents, and the introduction. Using the Inspector, Layout, Section, and selecting "Start at" 7 doesn't do anything!

    Is is a bit tricky, but it works. On your 6th page (the blank one) go to Insert > Section Break. This will give you a 7th page. Then go to Inspector (blue circle with a white letter i in it) and go to Layout Inspector (2nd tab). Once in thee, go to Section. Check "Start at" and enter the number 1. Then ensure all other toons I there are unchecked.
    Then go to Insert, and select Auto Page Numbers. You will find that your 7th page is numbered 1 as you want, but the first six pages will be numbered 1 to 6, which you don't want. But you can then delete the page numbering in that 1st section, leaving your 2nd section, beginning at page 7, numbered as page 1. You'll need to play around a bit as I did, and I would suggest using a test document to play with so you can undo any unwanted actions etc, but with tweaking around, it's doable. This took me ages to sort, so if it works for you, please give me the points :-)

  • How to show active page in Spry Menu Bar using images

    Hi,
    I have already read this answer "how to show active page in spry menu bar" but I am using images, not text.  I have mouse-over and mouse-out working in the Spry Menu Bar using image.png and image-over.png, but I cant' figure out how to get the image-over.png to appear on the active page since the spry menu bar is locked on the individual pages.  (I tried to put it in an editable comment, but spry wouldn't go for it. :-)
    Any ideas.  Here is the code:
    <ul id="MenuBar1" class="MenuBarHorizontal">
           <li><a href="../index.html" id="home" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image8','','../images/all_pages/home-over.png',1 )"><img src="../images/all_pages/home.png" alt="Home Page" name="home" width="58" height="20" border="0" id="Image8" /></a></li>
           <li><a href="../show.html" id="show" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('show','','../images/all_pages/show-over.png',1)"><img src="../images/all_pages/show.png" alt="The Show" name="show" width="101" height="20" border="0" id="show" /></a></li>
            <li><a href="../team.html" id="team" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('team','','../images/all_pages/team-over.png',1)"><img src="../images/all_pages/team.png" alt="The Team" name="team" width="97" height="20" border="0" id="team" /></a></li>
            <li><a href="../company.html" id="company" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('company','','../images/all_pages/company-over.png',1)"><img src="../images/all_pages/company.png" alt="The Company" name="company" width="139" height="25" border="0" id="company" /></a></li>
            <li><a href="../beatles-tickets.html" id="tickets" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('tickets','','../images/all_pages/tickets-over.png',1)"><img src="../images/all_pages/tickets.png" alt="Tickets" name="tickets" width="75" height="20" border="0" id="tickets" /></a></li>
            <li><a href="../media.html" id="media" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('media','','../images/all_pages/media-over.png',1)"><img src="../images/all_pages/media.png" alt="Media" name="media" width="61" height="20" border="0" id="media" /></a></li>
            <li><a href="../news-reviews.html" id="news" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('news_reviews','','../images/all_pages/news_reviews-over.png',1 )"><img src="../images/all_pages/news_reviews.png" alt="News-Reviews" name="news_reviews" width="149" height="20" border="0" id="news_reviews" /></a></li>
            <li class="MenuBarHorizontal"><a href="../contact.html" id="contact" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('contact','','../images/all_pages/contact-over.png',1)"><img src="../images/all_pages/contact.png" alt="Contact Us" name="contact" width="79" height="20" border="0" id="contact" /></a></li>
         </ul>
    Thanks so much for helping!
    Cheers,
    Janell

    Just found this page:
    Persistent Page Indicator
    Update: Drat, it is for text menus only not using images. :-(
    Cheers,
    Susan

  • I have scroll text box that is placed in a section of the page, It is in the right place on IE, Chrome, Safari, But not in Firefox?

    I have scroll text box that is placed in a section of the page, It is in the right place on IE, Chrome, Safari, But not in Firefox?
    Can anybody tell me why and how I can fix it. The page is baystatewiring.com/blog.html

    You need to make the text box float left.

  • TOC and Sections in a  Page Layout document?

    Is it possible to have a TOC and Sections in a  Page Layout document?

    Create a new, preceding document section, apart from your other document sections. Click in this empty document section, and then Insert > Table of Content > Document.

Maybe you are looking for