Automatically create numbers documents from one worksheet with a table

Hi,


I have got a worksheet with a table that contains several numbers and each row is for a new invoice. What I want to do with numbers is I want it to automatically pull the data from this sheet and automatically create me new numbers documents (invoices).


Is this possible? In MS Excel I've used Macros to do this for me, so I wonder if numbers offers something similiar. Automator?

MacBook Air, Mac OS X (10.7)

Posted on Sep 3, 2011 1:52 AM

Reply
37 replies

Sep 8, 2011 12:55 AM in response to enigma2k

enigma2k wrote:

I have started the last script version with the PDF function but I get this error msg: Applescript-Error: paragraph 2 of "15" can't be converted to type real. number -1700 from paragraph 2 of "15" to real

(I have translated this to English as English is not my system language, so it may not be the original error message)

I don't understand.


This morning I started from a HD where the script is not available so I borrowed it from my late message and it worked flawlessly.

Are you sure that you copied the posted script whithout any change ?


I missed the formula.


Here is a simpler one achieving the same goal :

=IFERROR(IF(FIND(D13,"AuIFRRa.Belgium.Bulgaria.Cyprus.Czech Republic.Denmark.Estonia.Finland.France.Germany.Greece.Hungary.Ireland.Italy.La tvia.Lithuania.LuxembORrg.NANDherlands.Poland.Portugal.Romania.SloPVkia.Slovenia .Spain.Sweden.United Kingdom"),"EU",""),"")


Yvan KOENIG (VALLAURIS, France) jeudi 8 septembre 2011 09:55:00

iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0

My iDisk is : <http://public.me.com/koenigyvan>

Please : Search for questions similar to your own before submitting them to the community

Sep 8, 2011 7:23 AM in response to enigma2k

I got the explanation.


The late script store two infos in the text file:

late invoice #

late conversion rate


but your old one contains only the late invoice #


Delete the text file or edit it with TextEdit


It must contain something like :


20

0.70602 if you use decimal period


or


20

0,70602 if you use decimal comma


It would have been a good idea to put a piece of code to treat this case.


I will send you a Numbers spreadsheet which may be used to merge your datas in a Pages document


The way of use is simple.


Open the spreadsheet

darg and drop the csv on the first sheet but outside the predefined table.

You will get the datas.

Select from A2 thru late cell of column I (drop column J)

Copy

Paste in cell A2 of the table "Merger"

Save

Then merge in a Pages document in which you will have inserted

merge fields matching the header names defined in the "Merger" table.


The result will be a Pages document with an invoice per page.

Export/Print it in a PDF and let's go.


I can't use that here because the original dates are wrongly imported when I start from your CSV.

As I wrote, the values dd.mm.yy are imported as yy.mm.dd


I tried to edit the resource containing the list of allowed entry date formats but I get always this old behavior.

So, for me, the unique usable answer would be the script.


Yvan KOENIG (VALLAURIS, France) jeudi 8 septembre 2011 16:22:55

iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0

My iDisk is : <http://public.me.com/koenigyvan>

Please : Search for questions similar to your own before submitting them to the community

Sep 8, 2011 12:31 PM in response to KOENIG Yvan

THANKS, deleting the text file did the trick and it is running now as it should. 🙂


The pdf output is in a strange format, however (I think it is an automatic format). As far as I understand the code you make use of the standard OSX PDF Save function, but why does it ignore the current settings for it?


Is there any way to change the PDF output to A4?


The solution you have come up with by dragging and dropping the csv directly into numbers, sounds intersting too. I don't understand, however, this step "Then merge in a Pages document in which you will have inserted

merge fields matching the header names defined in the "Merger" table."


How can I merge in a Pages document?

Sep 8, 2011 1:18 PM in response to enigma2k

enigma2k wrote:


THANKS, deleting the text file did the trick and it is running now as it should. 🙂


The pdf output is in a strange format, however (I think it is an automatic format). As far as I understand the code you make use of the standard OSX PDF Save function, but why does it ignore the current settings for it?


Is there any way to change the PDF output to A4?


As it's what I got whith your document when I used Share > PDF, I assumed that it was your own settings so I left it as is.

After reading your question I made complementary tests.

The file which was in your mail behaves exactly the same way on my machine supposed to use A4 paper size.

The only workaround which I found is :

Create a new Numbers document starting from the blank template.

Define its format as A4, portrait

Create a document with your template

Copy the table then paste it in the newly created document.

Save the new document as a template.

Go to the My Templates folder

Rename the original template as invoice_original.nmbtemplate

and

rename the new one as invoice.nmbtemplate.


The "Save in PDF" feature available thru AppleScript is supposed to mimic the Share > PDF feature, not the File > Print > Print in a PDF one.


The solution you have come up with by dragging and dropping the csv directly into numbers, sounds intersting too. I don't understand, however, this step "Then merge in a Pages document in which you will have inserted

merge fields matching the header names defined in the "Merger" table."


How can I merge in a Pages document?

You must do you user duty and study the Merge feature in Pages User Guide whose chapter 11 is entitled :


Personalizing Documents with Address Book and Numbers Data


This chapter is 7 pages long. I will not reprint it here.


Yvan KOENIG (VALLAURIS, France) jeudi 8 septembre 2011 22:14:36

iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0

My iDisk is : <http://public.me.com/koenigyvan>

Please : Search for questions similar to your own before submitting them to the community

Sep 8, 2011 4:26 PM in response to KOENIG Yvan

Thanks a million times again, I've managed to get the A4 format working with your workaround. I also did a bit experimenting with my template and the issue is that you have to extend the table itself to row 57, in order to get A4 format with Share --> PDF.


Thanks also for the tip with the Pages User Guide, did not know that this is an official feature.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Automatically create numbers documents from one worksheet with a table

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.