0

I'm literally going crazy to create a simple macro in writer. How do I get the number of all records of the selected query and move to the next record?

Below a piece of code.

odoc=thiscomponent
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
oVCur = oDoc.getCurrentController.getViewCursor 'ViewCursor für aktuelle Cursorposition holen
oField = oDoc.createInstance("com.sun.star.text.textfield.DatabaseNextSet")

With oField
    .Condition = "TRUE"
    .DataBaseName = NameSource 'database name
    .DataTableName = nameTable 'query name
    .DataCommandType = 1 '0 =table; 1=query
End With

'Line to go to next database record? '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
'Line to count all database record? '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
Fab
  • 31
  • 1
  • Is this a mail merge perhaps? Normally, connecting to a database is done in LibreOffice Base, not Writer. Please add a link that shows where you got this type of code from. Also, the term OpenOffice is no longer used, and those tags are deprecated. Are you asking about LibreOffice or Apache OpenOffice (AOO)? – Jim K Jun 13 '23 at 12:52
  • It is a writer macro command (oobasic language) linked to the OpenOffice package. My goal is to create a macro within writer that allows me to advance one record at a time in the related writer document connected to a database (mailmerge). I don't know if i'm explained. – Fab Jun 13 '23 at 13:19
  • I recommend that you search online for a complete explanation of how to do a mail merge and follow the instructions. If you get stuck, post a link to the instructions and describe where you got stuck. Also mention the name and version of the software you are using, for example, LibreOffice 7.5. – Jim K Jun 14 '23 at 16:08

0 Answers0