Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi :)
WoooHooo!!  Congrats on solving this one and thanks for posting the answer back to the list!  That 
might well help other people in the future or at least make the answer a bit easier to find.  


Thanks, congrats and regards from
Tom :)  






________________________________
From: Alain Van Utterbeeck <alain.vanutterbeeck@smartsolution.be>
To: users@global.libreoffice.org 
Sent: Tuesday, 20 August 2013, 14:18
Subject: Re: [libreoffice-users] LO WRITER BASIC : inserting a table using the dispatcher


I googled for a couple of hours to find this for a similar problem:
'probably this is due to the sometimes asynchroneous nature of the 
dispatch calls, try inserting a wait command'

So I changed the start of the code to:

                 if chapters.getBoolean(6) then
                     wait(120)
                     args4(0).Name = "TableName"
                     ...

and that solved my problem !

Thanks to all that helped me in getting my macro to work,

Greetings,
Alain


On 20-08-13 11:56, Alain Van Utterbeeck wrote:
Hello,

I have the following code in a macro:

                 if chapters.getBoolean(6) then
                     args4(0).Name = "TableName"
                     args4(0).Value = "Tabel1"
                     args4(1).Name = "Columns"
                     args4(1).Value = 3
                     args4(2).Name = "Rows"
                     args4(2).Value = 2
                     args4(3).Name = "Flags"
                     args4(3).Value = 11
                     dispatcher.executeDispatch(document, 
".uno:InsertTable", "", 0, args4())
                     args1(0).Name = "Text"
                     args1(0).Value = "Product"
                     dispatcher.executeDispatch(document, 
".uno:InsertText", "", 0, args1())
                     dispatcher.executeDispatch(document, 
".uno:JumpToNextCell", "", 0, Array())
                     args1(0).Name = "Text"
                     args1(0).Value = "Hoev."
                     dispatcher.executeDispatch(document, 
".uno:InsertText", "", 0, args1())
                     dispatcher.executeDispatch(document, 
".uno:JumpToNextCell", "", 0, Array())
                     args1(0).Name = "Text"
                     args1(0).Value = "Prijs"
                     dispatcher.executeDispatch(document, 
".uno:InsertText", "", 0, args1())
                     sale_order_lines=DBsql4.executeQuery("SELECT name, 
product_uom_qty, " + _
                                         "(product_uom_qty * 
price_unit) AS amount, " + _
                                         "(SELECT seq_document from 
product_product where product_product.id = sale_order_line.product_id) 
AS seq " + _
                                         " FROM sale_order_line WHERE " 
+ _
                                         "order_id = " + sale_order_id 
+ " ORDER BY seq")

                     While sale_order_lines.next
                         naam=sale_order_lines.getString(1)
                         qty=sale_order_lines.getString(2)
                         amount=sale_order_lines.getString(3)
                         args1(0).Name = "Text"
                         args1(0).Value = naam
                         dispatcher.executeDispatch(document, 
".uno:JumpToNextCell", "", 0, Array())
                         dispatcher.executeDispatch(document, 
".uno:InsertText", "", 0, args1())
                         args1(0).Name = "Text"
                         args1(0).Value = qty
                         dispatcher.executeDispatch(document, 
".uno:JumpToNextCell", "", 0, Array())
                         dispatcher.executeDispatch(document, 
".uno:InsertText", "", 0, args1())
                         dispatcher.executeDispatch(document, 
".uno:NumberFormatDecimal", "", 0, Array())
                         args1(0).Name = "Text"
                         args1(0).Value = amount
                         dispatcher.executeDispatch(document, 
".uno:JumpToNextCell", "", 0, Array())
                         dispatcher.executeDispatch(document, 
".uno:InsertText", "", 0, args1())
                         dispatcher.executeDispatch(document, 
".uno:NumberFormatDecimal", "", 0, Array())
                     Wend
                     mCurs.gotoEnd(False)
                 end if

The result that I get is:



Does anybody have an idea why the dispatcher.executeDispatch(document, 
".uno:JumpToNextCell", "", 0, Array()) is not working?

The crazy thing is that if I put a breakpoint on the first line of 
this code, and go through it step by step, it works fine  and I get :


Another strange thing is that the third column containing the price is 
set to 0 while in the first screenprint, if you look closely at the 
contents that is completely in the first cell, the prices are not 0 !!!

Any ideas please?

Thanks in advance for any help...

Greetings,
Alain




-- 
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted



-- 
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.