Thursday, October 17, 2019

#1 2019-09-16 03:23:21 pm

jimmy25
Member
Registered: 2019-09-11
Posts: 1

opening numbers document

Hi,

Sorry, my English is not very good...

I'm working on a project using numbers and applescript.

In a first document, I've got a list of invoices. In a folder I've got all invoices as numbers documents.

I would like to open one of these invoices. All these files have a composed named like : order number - name of client - name of job - date of job.

I don't manage to create a string using the first cell of the table witch contains the composed name. So, I've used all the informations of the table to re-create the string... sad

But finally, when I try to use this string to open the document, I can only obtain the last information of the string, so the name of document is wrong.

e.g. 206 - Symphonie - Concert - 25/10/2019 & ".numbers" returns only "2019.numbers"

Here is the code :

Applescript:


tell application "Numbers"
   activate
   
   
   -- créer une liste des dossiers
   tell the first table of the sheet "donnees" of the document "liste_dossiers"
       
       set ref_a_chercher to {}
       
       repeat with n_ref_a_chercher from 2 to row count
           set end of ref_a_chercher to the value of cell 1 of row n_ref_a_chercher
       end repeat
       
       -- boîte de dialogue de choix du dossier
       set reference_dossier to choose from list ref_a_chercher with prompt "Choisir le client"
       
       
       -- creation de la reference
       repeat with n_infos from 2 to row count
           if the value of cell 1 of row n_infos contains reference_dossier then
               set D_num to the value of cell 2 of row n_infos
               set D_client to the value of cell 3 of row n_infos
               set D_event to the value of cell 4 of row n_infos
               set D_date to the value of cell 5 of row n_infos
           end if
       end repeat
       
       set dossier_ouvrir to D_num & " - " & D_client & " - " & D_event & " - " & D_date & ".numbers"
               
       open ("/Users/jimmy/Documents/compta/dossiers/" & dossier_ouvrir) as POSIX file
       
   end tell
end tell

Could you please help me?

How should I use the information contained in the first cell as text format to open the document?
=> order number - client - event - date

Thanks a lot !

Jimmy

Last edited by jimmy25 (2019-09-16 03:36:24 pm)


Filed under: Open document

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)