Previous 1 2 3 4 5 Next 66 Replies Latest reply: May 3, 2009 6:07 AM by lbrookins Go to original post
  • Roger Wilmut1 Level 9 Level 9 (71,355 points)
    Thanks, I'll give that one a try. (And, yes, of course, c not v)
  • Roger Wilmut1 Level 9 Level 9 (71,355 points)
    Your conversion script works well: I tried it with the Family Tree, and it handled the layout well - the main difference is that the leading in Pages is greater than in AW and needs to be set to 0.9. It still creates extra pages, and I haven't worked out how to get rid of them (it keeps trying to delete all the pages).

    However this:

    tell application "Numbers"
    activate
    set document1 to name of document 1
    set document2 to name of document 2
    tell document document2
    activate
    end tell
    end tell

    should in theory bring the rear document to the front and in fact nothing happens.
  • Level 8 Level 8 (41,790 points)
    (1) I already explain that the extraneous pages are due to the fact that in your original file some objects are greater than a single page so, the script is forced to take care of that.
    It can't decide by itself if the width of the original document is only one page.
    I will continue to search where is stored the info about the number of pages in width and in height is stored in the documents.

    (2) there is no need to bring a document at front to speak to it.
    If you really want to bring one at front, you may use this handler which is OK for Pages and Numbers:


    tell application "Numbers"
    set doc1 to name of document 1
    set doc2 to name of document 2
    my selectDoc("Numbers", doc2)
    tell document doc2
    --
    end tell
    end tell

    on selectDoc(a, n)
    if a = "Pages" then
    set f to 9
    else if a = "Numbers" then
    set f to 10
    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 f to tell menu 1 to click menu item n
    end selectDoc


    Yvan KOENIG (from FRANCE mardi 21 avril 2009 12:15:09)
  • Roger Wilmut1 Level 9 Level 9 (71,355 points)
    Yes, that works fine, thank you.

    Here's an interesting one. In an AppleWorks document I have some text in columns, separated by tabs, with different colour text to convey information.

    I set up a document in Pages. I set up the tabs to be correct for the columns in the other document. I copy the other document, and paste it into Pages.

    Pages shows the document with the correct colours, but the tabs are replaced with the multiple tabs shown on a new blank page.

    I set up the tabs manually. I select the text, and set a paragraph style to it. I delete the text.

    Now I paste the text again: again the tab settings are lost. I select all the text and invoke the style: the correct tabs appear and the columns show correctly, but, the text colour goes all the same. I can see no way round this one (it works perfectly well in AppleWorks). Obviously I can set up the tabs manually, but the whole point is to automate the process.
  • woodsbr3 Level 1 Level 1 (0 points)
    Hi

    I've fixed it - I had a look at what version of appleworks 6 I had and it was only 6.2.2.. I ran the updater for appleworks to upgrade to 6.2.9 and it all works. Thanks heaps for your help

    Brian
  • Level 8 Level 8 (41,790 points)
    (1) I assume that it's the selectDoc handler which works OK.
    (2) I think that I found a way to get rid of the extraneous blank pages.

    May you check that this script:



    set cheminsource to (choose file with prompt "Choose an AppleWorks Draw document…" of type {"com.apple.appleworks.cwk"}) as text

    set enTexte to read file cheminSourceGR from 27 for 24
    set measures to {}
    repeat with i from 1 to count of enTexte by 2
    copy ((ASCII number of character i of enTexte) * 256) + (ASCII number of character (i + 1) of enTexte) to end of measures
    end repeat

    tell measures
    set isLandscape to (item 3 < item 4)
    set {mG, mH, mD, mB} to {item 6, item 5, item 8, item 7}
    set page_Width to (item 4) - mG - mD
    set page_Height to (item 3) - mH - mB
    end tell -- measures
    set enTexte to read file cheminSourceGR from 1800 for 6
    set measures2 to {}
    repeat with i from 1 to count of enTexte by 2
    copy ((ASCII number of character i of enTexte) * 256) + (ASCII number of character (i + 1) of enTexte) to end of measures2
    end repeat

    if isLandscape then
    set {beg, ww, hh} to {2138, 3, 1}
    else
    set {beg, ww, hh} to {1800, 1, 3}
    end if
    set enTexte to read file cheminSourceGR from beg for 6
    set measures2 to {}
    repeat with i from 1 to count of enTexte by 2
    copy ((ASCII number of character i of enTexte) * 256) + (ASCII number of character (i + 1) of enTexte) to end of measures2
    end repeat
    set doc_width to item ww of measures2
    set doc_height to item hh of measures2
    set nbPagesWidth to doc_width div page_Width
    set nbPagesHeight to doc_height div page_Height

    display alert "isLandscape : " & isLandscape & return & "measures : " & my recolle(measures, ", ") & return & "page_Width : " & page_Width & return & "page_Height : " & page_Height & return & "measures2 : " & my recolle(measures2, ", ") & return & "doc_width : " & doc_width & return & "doc_height : " & doc_height & return & "nbPagesWidth : " & nbPagesWidth & return & "nbPagesHeight : " & nbPagesHeight

    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


    returns the correct numbers of pages in width and in height of Draw documents.

    Just run it, it will ask you to select a Draw document and will display some parameters.
    Here, I got correct results but I wish to be sure that it's OK before changing the scripts.

    (3) I'm not sure than I understand well the question about tabs.
    When a Draw document containing text frames with tabs embedded, all the features of these tabs are correctly passed thru my scripts.
    When we use copy paste from AppleWorks to Pages I'm not surprised that some attributes are lost.
    The ruler is not passed during the "normalization" process of the clipboard's contents.
    It would be better to import your document.

    Yvan KOENIG (from FRANCE mardi 21 avril 2009 19:03:50)
  • Roger Wilmut1 Level 9 Level 9 (71,355 points)
    I'll look at your script tomorrow; thank you.

    As to the tabs problem, the actual situation is that I have a database in which I enter future programs to record on my various machines - Sky+, Freeview PVRs, etc. Each record contains the date, time, title and duration, and the text is coloured to indicate the machine to be used.

    Each week the entries for the following week are selected and copied into a word processing document, which has been set up in columns, divided by vertical lines, using tabs. In AppleWorks I can select the week's entries in the database, then paste into the blank word processing template. The tabs are retained when I paste, as is the text colour, so only minor reformatting is involved.

    Trying this in Pages works as I describe: on paste you retain the colours but the tab setup is replaced by the infuriating default one of a tab every half inch or so. It's impossible to copy and paste the ruler (as in AW), and using a paragraph style produces the correct tabs but loses the different colours. So all these extra tabs have to be removed and the correct positions set by hand, and so far I can see no way round this.
  • Level 8 Level 8 (41,790 points)
    I repeat that it's the normal behavior.

    When you copy paste from AW6_DB to AW6_WP you remain in AW6 so the clipboard keeps all the features defined in the application. It's what we call a"private clipboard".
    When you paste in Pages, you leave the "private clipboard". This requires what is called "clipboard normalization". This drop a lot of features retaining only a short subset of features.

    A workaround would be to copy from the DB, paste in a n AW6 WP then import this WP in Pages.

    It's easy to do an it's eaven easy to drive with an AppleScript.
    It's the kind of tip which I use to insert styled text in Numbers cells with AppleScript.

    Yvan KOENIG (from FRANCE mardi 21 avril 2009 21:19:29)
  • Level 8 Level 8 (41,790 points)
    Here is a script which pass converts the AW clipboard into a Pages one retaining every attributes.


    (* copy some styled datas from an AppleWorks 6 document,
    from a database for instance.
    Run the script.
    It will paste in a temporary AW6 WP.
    It saves the document then close it.

    Pages is asked to open this WP.
    The script selects all,
    copy to the clipboard
    close the temporary Pages document.

    Yvan KOENIG (Vallauris, FRANCE)
    21 avril 2009
    *)

    on run

    set WPname to "fromDB2WP.cwk"
    set p2t to path to temporary items as text
    set p2tWP to p2t & WPname
    tell application "System Events"
    if exists file p2tWP then delete file p2tWP
    make new file at end of folder p2t with properties {name:WPname, file type:"CWWP"}
    end tell
    tell application "AppleWorks 6"
    activate
    make new document at front with properties {document kind:text document, name:WPname}
    tell document WPname
    paste
    end tell
    save document WPname in (p2tWP as alias)
    close document WPname
    end tell -- AppleWorks

    tell application "Pages"
    open file p2tWP
    set pName to name of document 1
    tell document pName
    --
    end tell
    my shortcut("Pages", "ac")
    close document pName saving no
    end tell -- Pages
    (* now the original AW clipboard is replaced by a Pages one whith all original attributes *)
    end run

    --=====

    on shortcut(a, t)
    tell application a to activate
    tell application "System Events" to tell application process a
    repeat with i from 1 to count of t
    keystroke ((character i of t) as text) using {command down}
    end repeat
    end tell
    end shortcut

    --=====


    As I wrote, it was really easy top build it

    Yvan KOENIG (from FRANCE mardi 21 avril 2009 22:00:34)
  • Roger Wilmut1 Level 9 Level 9 (71,355 points)
    A workaround would be to copy from the DB, paste in a n AW6 WP then import this WP in Pages.


    Indeed; but the whole point of the exercise is to drive a move away from AppleWorks. Ultimately I expect to migrate to Pages and to replace the database module with FileMaker - not necessarily right away, but when the day comes that AW won't run for whatever reason I want to be ready at that point, not starting the research process. I've done pretty well, with your kind help, but this one is a bit of a sticking point. What we need is the 'copy ruler/apply ruler' facility - that would solve it but unfortunately it's been replaced by the Paragraph Styles. It wouldn't be so annoying if the default tabset wasn't so many tab points to remove.
  • Roger Wilmut1 Level 9 Level 9 (71,355 points)
    Here is a script which pass converts the AW clipboard into a Pages one retaining every attributes.


    That looks brilliant - can't wait to try it tomorrow (on Linux at the moment where it wouldn't run too well).
  • Roger Wilmut1 Level 9 Level 9 (71,355 points)
    Yvan: reporting on your script which checks the parameters of an AW Draw document, tested with the Family Tree document I sent you.

    The first line should read
    set cheminSourceGR to (choose file.....

    The script reports this:


    It doesn't seem to state the number of pages (3). It would be helpful if it coped this result to the clipboard since it can't be selected and copied.

    I'll report on your other script in a separate post.
  • Roger Wilmut1 Level 9 Level 9 (71,355 points)
    Yvan: regarding the script which converts from the AW clipboard to the Pages one. It works when the copy is done from an AW WP document which carried the correct tabs. Unfortunately, it doesn't work when (as is the intention) the copy is made from a database, because although the clipboard contains tabs and returns it doesn't, obviously, contain any tab settings.

    What we are falling over is the difference in the way AW and Pages deal with pasting. For example: if you have a clipboard containing text which simply includes tabs and returns, and you have WP documents in both AW and Pages which have correct tab positions set up, then different things happen:

    Pasting into the AW document retains the tabs which were set and aligns the pasted text with them.

    Pasting into the Pages document replaces the preset tabs with the default multiple tabs you get in a new document.

    In the specific case of pasting from a database I'm afraid your script doesn't help. Obviously, I could paste into a properly set up AW document first, and then run your script: that works fine, but in that case one might just as well print from the AW document (and the ultimate intention is to do this from FileMaker where this option wouldn't apply).

    However, I'm very grateful to you for trying, and I shall certainly hang on to your script as it's bound to be useful sooner or later.
  • Level 8 Level 8 (41,790 points)
    If you have to do the trick often, it would be useful to build a merge document which will grab the infos from the DB to a word processor.
    Given that, the values will benefit of the ruler installed in the merged document.

    It's an old workaround but it may be useful here.

    Yvan KOENIG (from FRANCE mercredi 22 avril 2009 11:20:00)
  • Level 8 Level 8 (41,790 points)
    Thanks for the feedback.

    As You aked me, I destroyed the sample file which you sent me.
    Given your comment, I scrapped my head and realized that maybe it was available in Mails archives. Happily it was.

    So I was able to look in its internals.
    I discovered that old documents created with old AppleWorks 5 have a structure different than those created directly in AppleWorks 6.
    This will make the task more complex but I am on the track

    OK for the request about passing the result in the clipboard.

    Yvan KOENIG (from FRANCE mercredi 22 avril 2009 11:33:54)