Move a block of text from one document to another

How to make a script moving a block of text from a defined area to next document?

Here is the beast.
--[SCRIPT exportTextBlocks]
Save the script as a Script, an Application or an Application Bundle: exportTextBlocks.xxx
Move the newly created application into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Pages:
Maybe you would have to create the folder Pages and even the folder Applications by yourself.
select something in the source document
menu Scripts > Pages > exportTextBlocks
creates a new Pages document with the chunks of texts which where delimited by the markers.
--=====
The Finder's Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the "Show Script Menu in menu bar" checkbox.
--=====
Yvan KOENIG (Vallauris, FRANCE)
26 avril 2009
--=====
Here it would be easy to edit it if required
property marker : "______"
on run
my activateGUIscripting()
tell application "Pages" to tell document 1
set nDocSource to name
set source to body text
end tell -- Pages
set source to my decoupe(source, marker)
set extraits to {}
repeat with i from 1 to ((count of source) - 1) by 2
copy item (i + 1) of source to end of extraits
end repeat
copy "" to end of extraits
set extraits to my recolle(extraits, marker & return)
set destName to dateTimeStamp() & ".pages"
set destDoc to my makeNewPagesDoc(destName, path to documents folder as text)
tell application "Pages"
set body text of document destName to extraits (* inserts the extracted blocks *)
save document destName
my selectIworkDoc(name, nDocSource) (* back to source document *)
end tell -- Pages
end run
--=====
on decoupe(t, d)
local l
set AppleScript's text item delimiters to d
set l to text items of t
set AppleScript's text item delimiters to ""
return l
end decoupe
--=====
on recolle(l, d)
local t
set AppleScript's text item delimiters to d
set t to l as text
set AppleScript's text item delimiters to ""
return t
end recolle
--=====
on dateTimeStamp()
return (do shell script "date " & quote & "+P%Y%m%d-%H%M%S" & quote)
end dateTimeStamp
--=====
on makeNewPagesDoc(n, d)
local f, t
set f to d & n
set t to ((path to applications folder as text) & "iWork '09:Pages.app:Contents:Resources:Templates:Blank.template:") as alias
tell application "Pages"
open t
save document 1 as n in file f
end tell -- Pages
return d as alias
end makeNewPagesDoc
--=====
Use GUI scripting
on selectIworkDoc(a, n)
local m
if a = "Pages" then
set m to 9
else if a = "Numbers" then
set m to 10
else if a = "Keynote" then
set m to 11
else
error "The application “" & a & "“ is not accepted !"
end if
tell application a to activate
tell application "System Events" to tell application process a to tell menu bar 1 to tell menu bar item m to tell menu 1 to click menu item n
end selectIworkDoc
--=====
on activateGUIscripting()
tell application "System Events"
if not (UI elements enabled) then set (UI elements enabled) to true (* to be sure than GUI scripting will be active *)
end tell
end activateGUIscripting
--=====
--[/SCRIPT]
Yvan KOENIG (from FRANCE dimanche 26 avril 2009 22:32:24)

Similar Messages

  • I have never used PS, and I am trying to edit a brochure created by someone else.  I need to move text from one column to another

    I have never used PhotoShop and do not have time at the present. Please help me to move a section of text from one column to another in a brochure.

    Here are 3 options for future reference:
    1. With the setup you've described, apply a Match Move behavior to  the text and make the rectangle the source. Change the Transform parameter to Mimic source.  This way you can still adjust the text postion as needed, but the rectangle will drive the animation.
    2. Use a group to do the animation.  Put both your rectangle and text in the same group and animate the group's postion.
    3. Use the Link behavior.
    Each of these has it's advantages depending on what you need.

  • [CS3 JS]  Move pages from one document to another?

    First, a brief explanation of what I am trying to do. I have several individual chapters that I am including in an INDD book. However, I also want to be able to allow those individual chapters to stand alone, meaning that I want to add a cover/title page to each chapter file (these two pages would be placed before the current page 1 of each chapter).
    My preference would be to write a script that would open the cover/tp file and open the first chapter file; this part is no problem. Where I am running into trouble however, is the second step: moving the cover/tp pages (2 pages) over into the chapter file.
    Manually, I would open Cover.indd, activate the "move pages" menu, "Move pages: 1-2", "Destination: Before_Page 1", "Move to: Chapter1.indd".
    With over 100 chapters in the book, however, I would prefer to automate the process. I have looked into the Page.move and PageItem.move elements, but both look like they would require a location in the current document (either in (x,y) form or using "AT_BEGINNING".
    If I cannot get this to work, I will likely try to insert two blank pages, then cut/paste with a script, but I would prefer the "move" functionality, if it is possible.
    A couple of answers to potential questions:
    I can't simply place the INDD cover file b/c it uses a text variable to pull the chapter name; this personalizes each stand-alone chapter.
    Same answer to why I can't just slap the 2-page .pdf on the front of each. I need the text variable to still be active.
    Has anyone tried to move pages from one document to another using scripting? I tried to explain what I am trying to do, but if it doesn't make sense, I can try again. :)
    thanks!
    Matt

    ok here we are
    I get a raw skeleton that you will have to adjust but it's functional.
    Use a PDF for placement as you can specify the page that you want to place.
    I don't know if you can do the same for indesign files.
    So basically, it starts adding 2 pages and placeing the pdf in the same time.
    After that, it creates the textVariable and the frame that will receive it.
    Here you are:
    //If a document is open
    if(app.documents.length!=0)
    var ad = app.activeDocument;
    //Pages placement
    for(i=0; i<2; i++)
    //Add 2 pages on top of the document;
    var tmpPg = ad.pages.add(LocationOptions.BEFORE, ad.pages[0]);
    //Here you place your pdf
    app.pdfPlacePreferences.pageNumber = i;
    tmpPg.place(File(cover.pdf), false)
    //You should specify page x and page y but ain't found yet the way to go.
    //Text variable creation
    //Check if the textVariable named "txtVar" does not already exist...
    if(ad.textVariables.item("txtVar")==null)
    //if not found, create the text variable named "txtVar"
    var txtVar = ad.textVariables.add();
    txtVar.variableType =VariableTypes.CUSTOM_TEXT_TYPE;
    txtVar.name = "txtVar";
    //Set the contents of the text variables to the string "test"
    ad.textVariables.item("txtVar").variableOptions.contents = "test";
    //these coordinates don't care aboutyour units but you may adjust them to your needs
    var y1 = ad.marginPreferences.left;
    var x1 = ad.marginPreferences.top;
    var y2 = y1+5;
    var x2 = x1+25;
    var myFrame = ad.pages[0].textFrames.add({geometricBounds:[y1,x1,y2,x2]});
    //Set the contents of the frame to the text variables "txtVar"
    myFrame.contents=ad.textVariables.item("txtVar").variableOptions.contents;
    //You may want to stylize the txtVar
    //In this case, either you use a existing characterStyle or you create one in the script
    Bye Loic

  • Copy/Move Layerset From One Document To Another Without Flattening

    Hello,
    Does anyone know how to move a layerset from one document to another using JavaScript ExtendScript, but without having to flatten the layers first as I still need to edit them after the move.
    Many Thanks,
    James

    This requires that you have the the two documents open the first document open is the one you are copying from with the layer/layers selected.
    activeDocument=documents[0];
    dupLayers();
    function dupLayers() {
        var desc15 = new ActionDescriptor();
            var ref12 = new ActionReference();
            ref12.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
        desc15.putReference( charIDToTypeID('null'), ref12 );
            var ref13 = new ActionReference();
            ref13.putName( charIDToTypeID('Dcmn'), documents[1].name );
        desc15.putReference( charIDToTypeID('T   '), ref13 );
        desc15.putInteger( charIDToTypeID('Vrsn'), 2 );
        executeAction( charIDToTypeID('Dplc'), desc15, DialogModes.NO );

  • Move text from one artboard to another

    Hi I have 3 artboards open and am trying to move text from one artboard to another, each piece of text is on a different layer, but when I use the selection tool and just drag it across to the next artboard, nothing shows up.  How do I move text from one artboard to another?  Thanks

    Dont worry I now have it sussed.  I just needed to move the layers up in the stacking order.

  • Move (or copy or cut and paste) entire sheet from one document to another.

    I have several sheets I want to move from one document to another and retain all formatting and spacing, etc.
    What is the best way to do this?
    Thanks

    On the left of the screen is the list of sheets and tables and charts. Select the sheet. Copy. Paste into the same area (i.e., in the area where the sheets are listed) of the new document.

  • Cannot move the pages from one document to another

    Hi,
    I cannot move the pages from one document to another, abobe gets crashed. I am not sure but I think this was happening when I try to copy or move the threaded content. How to resolve this, this is happening in both CS4 and CS5. Can anyone help me?

    Thanks for ur reply.
    1. Open two documents, for ex doc1 and doc2, doc1 contais 4 pages, doc2 contains 2 pages
    2. Using Move Pages from the Pages panel menu in doc1, moving 1st two pages to doc2
    Move Pages  : 1-2
    Destination   : After page 1
    Move to        : doc2
    Actually I was not able to copy the textframe which is linked with another, immediately it crashes.

  • How to block calls & texts from one telephone number

    How to block calls & texts from one telephone number

    Call number blocking is done only by the carrier. Some carriers allow users to input numbers to be blocked on a website.
    Verizon allows users to list up to five numbers to be blocked for free for 90 days by entering them in the users My Verizon site. I've found that 90 days has been sufficient to discourage most nuisance calls. But Verizon also provides a service ( for a fee) that will permanently block a number.
    So contact your carrier to see what they offer.

  • How do I copy an art object from one document to another using illustrator API(C  )

    Hi, I'm trying to copy text and graphic elements from one document into another, does anybody has an idea how to do it using Illustrator SDK(C++)?
    Thanks in advance.

    If you call AIArtSuite::ReorderArt() giving the layer group handle from the target document and using art from the source document, it will move art between documents. That said, there are all sorts of caveats that come along with that -- some things move over automatically (graphic styles, symbols) while others cause problems. E.g. copying art that contains a swatch can cause a crash when you shut down the source document because it may keep the style reference to the swatch in the source document -- which goes away when the document is closed. Gradients in particular are a problem I believe. Straight up colours are (I think) fine. I've had to write a lot of workarounds for various headaches caused by moving art between documents.
    Bottom line: its very doable, but there are a lot of edge cases. This was clearly not an intended use of the SDK, though it is possible.

  • Copy an Image from one document to another

    Is there an easy way to copy a rectangle containing an image (not a link to an image) from one document to another?
    Thanks.
    Chris.

    I can now copy-paste text frames and linked graphics from one document to another using snippets, but embedded images still don't work.
    If I embed an image from a pdf file it works but not for jpeg images. When I open the new document (for which I placed the snippet) in InDesign, there is a frame (with a dark grey background and a diagonal cross) shown, but no contents. The place() method did not throw an exception. What am I doing wrong?
    Chris.

  • Can Pages copy text from one page to another automatically?

    Can Pages automatically copy text from one page to another?
    For example recurring text in a document e.g. addressee details or a date (not today's date).
    I want to type the topic title of one letter and have it automatically filled into the correct field in the next page which will be a letter to a different recipient.
    The letter text will be different for each recipient so mail merge probably won't work.
    Thanks
    Andy

    Thanks that worked great!!!(for the first line)
    Now why wont it populate more than the one other text field?
    F.Lic.Table1.Row1.agt_ssn_lic.rawValue = xfa.event.newText;
    F.PAGE3.agt_ssn_1.rawValue = xfa.event.newText;
    F.PAGE4.agt_ssn_2.rawValue = xfa.event.newText;

  • Inserting text from one JTextpane to another

    How do i insert text from one jTextpane to another with the attributes i used in the first. Please help.

    i'm using a defaultstyleddocument. Also.....if u know
    how i can transfer this data through a
    DataOutputStream to another computer.Hi again,
    DefaultstyledDocument uses a tree-structure with classes in it, that implements the Element-Interface to hold the styles. It is very easy to get the plain text, but what you need to transfer a part of text from one JTextPane with DefaultStyledDocument in it to another with the same document-style in it, is a sequence of (string, AttributSet) - pairs, so you are able to insert them in the destination document by the insertString(...)-method.
    It is easy to get the Element by postion from the document and retrieve the Attributset from it that it uses in that position. I guess, an approach would be, to do the following:
    get the Attributset at the start of the text = AttributSet of the pair
    scan the document until the set changes
    extract the string from start to the position right before the set changes = string of the pair
    store the (String,AttributSet)-pair in a Vector
    do this in the same way, but this time the "start" will be the position of the start of the new Attributset that causes the end of the scan above.
    When this is done for the hole text, that is to be transferred, you have a Vector with the String-AttributSet-pairs that you can use to insert them in the other JTextPane by calling the
    insertString(...)-method with this values.
    Tell me, what you are thinking about that - I don't know another method for this and had to create a solution on the fly for you, so that is perhaps not the best way to do it.
    greetings Marsian

  • How can I move the ODI Work Repository from one server to another server?

    How can I move the ODI Work Repository from one server to another server?

    Hi,
    If you would like to move your source models, target models and project contents from Work repository 1 to another work repository.
    I.e. Dev. server to Prod Server.
    1. Firstly, replicate the master repository connections i.e. with same naming conventions manually
    2. Go to Dev. Server work repository -> File Tab -> Click on Export work repository (save it in a folder)
    3. After exporting, you can view the xml files in the folders.
    4. Now, Open the Prod. server and make sure you already replicated mas. rep. details.
    5. Now, right click on model and import source model in synonym mode insert_update (select source model from the folder where your xml file located)
    6. Similarily, import again target then Project.
    Now, check. It should work.
    Thank you.

  • How can I copy text from one card to another while creating cards using Iphoto?

    I created two cards with different pictures using Iphoto on Macnotebook. 
    I want to use the same text message.
    How can I copy text from one card to another?

    select the text and copy (edit menu ==> copy) tehn gpo to the next card and paste
    LN

  • How do I copy text from one layer to  another?

    I have Googled this but not a single answer seems to work.
    I am using Photoshop CS4 on OS X 10.6.7.
    OK, so  I  have a layer that  has some text in it.  I would like to  be able to  simply copy that  text  from one layer  to  another, but this seems to  be impossible as the Edit Paste menu item is grayed out after I have copied it in to the clipboard.  I can paste it into  the SAME layer, but not into another layer.
    This is how I am trying to  do  this.
    In the layer  with the text, click on the "T" icon to  the left.
    Click on the text, in the layer that I  want to  copy. 
    I select the text (either  by  clicking and dragging or pressing Command-A).
    Next I press Command-C.
    Then I  click on the layer In the Layer Panel) where I want to  paste the text.
    Pressing Command-V is impossible because the Edit-Paste menu option is grayed out!!!!
    WHY??????
    Perhaps more importantly, HOW do I copy text  from one layer to  another?

    First thing you can simply right click on the Text Layer and choose Duplicate Layer.  But that will create a new Text Lay
    er identical to the one you have.
    To answer your question in your case....  Create the Text Layer.   Make a New Layer.  Or have the layer you want to paste into visible.
    Highlight the text layer in the Layer Palette and Ctrl+Click (Win) Cmd+Click(Mac) so that you see marching ants walking around your text.
    Edit>Copy.
    Then highlight your Layer you want to paste into and hit Edit>Paste or Cmd+V / Ctrl+V.

Maybe you are looking for