CONCATENATE macro program

Creating a macro - Writing a Script - Using the API

CONCATENATE macro program

Postby chandrankrishnan » Tue Sep 12, 2017 11:16 am

Hi all,Good day to you
can anyone help me with a concatenate macro program for the attached sheet.

i add tried with recordings but result varies from cell to cell.

I Uploaded my sample attachment sheet.

Thanks in advance
Attachments
CONCATENATE mac.ods
(15.59 KiB) Downloaded 61 times
OpenOffice 4.1.2 windows vista
User avatar
chandrankrishnan
 
Posts: 63
Joined: Sat Mar 05, 2016 1:21 pm

Re: CONCATENATE macro program

Postby Zizi64 » Tue Sep 12, 2017 11:21 am

i add tried with recordings but result varies from cell to cell.


Recording a macro is not an efficeient way to create macros. The macro recorder can not record all of user's activity, and it works in the Calc and the Writer applications only.

You need WRITE your macros based on the API functions. You can use one of the supported programming languages to call the API functions.
Tibor Kovacs, Hungary; LO4.4.7, LO6.1.6 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.4; AOO4.1.5
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 7965
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: CONCATENATE macro program

Postby chandrankrishnan » Tue Sep 12, 2017 11:48 am

Hi zizi64,
Thanks for the reply.
I am in starting stage and studying macro program with help of forum only.so please guide me in this.
OpenOffice 4.1.2 windows vista
User avatar
chandrankrishnan
 
Posts: 63
Joined: Sat Mar 05, 2016 1:21 pm

Re: CONCATENATE macro program

Postby Villeroy » Tue Sep 12, 2017 12:16 pm

This is not the place where you can learn how to program.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26709
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: CONCATENATE macro program

Postby RoryOF » Tue Sep 12, 2017 12:18 pm

You need to study Andrew Pitonyak's books on macro programming. These are at
http://www.pitonyak.org/oo.php
Apache OpenOffice 4.1.6 on Xubuntu 18.04.2 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 28918
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: CONCATENATE macro program

Postby chandrankrishnan » Tue Sep 12, 2017 2:33 pm

Hai all,
i tried with below macro program instead sum i changed with concatenate(with &function) but comma is not adding.please guide me in this.
Code: Select all   Expand viewCollapse view
sub addAndMerge(event)

oSheet = thisComponent.Sheets(0)
oSheet.Columns.insertbyindex(7,2)
oSheet.getCellRangeByName("H1").String = " TOTAL QTY"
oSheet.getCellRangeByName("I1").String = " SL NO"
    doc = thiscomponent
    sheet = doc.CurrentController.ActiveSheet
    sum = 0
    row = 1   
    first = row
    counter = 1
    do
        range = sheet.getCellRangeByPosition(3, row, 8, row+1)
        data = range.DataArray
        sum = sum & data(0)(3)
       
        if data(0)(0) <> data(1)(0) then
            sheet.getCellByPosition(7, first).setValue(sum)
            tobemerged = sheet.getCellRangeByPosition(7, first, 7, row)
            tobemerged.merge(True)
            sheet.getCellByPosition(8, first).setValue(counter)
            tobemerged = sheet.getCellRangeByPosition(8, first, 8, row)
            tobemerged.merge(True)
           
            sheet.Columns.removeByIndex(16, 1)
            sum = 0
            first = row + 1
            counter = counter +1
        end if
        row = row +1
    loop until data(1)(0) = ""
end sub
Last edited by RoryOF on Tue Sep 12, 2017 2:36 pm, edited 1 time in total.
Reason: Added [Code] tags [RoryOF, Moderator]
OpenOffice 4.1.2 windows vista
User avatar
chandrankrishnan
 
Posts: 63
Joined: Sat Mar 05, 2016 1:21 pm

Re: CONCATENATE macro program

Postby Villeroy » Tue Sep 12, 2017 2:41 pm

What are you trying to do? The "output" range on your spreadsheet makes no sense. The spreadsheet's formula language can concatenate. Merging cells is a misunderstood anti-feature. Merging has nothing to do with concatenation.
=A1&","&B1
=CONCAT(A1;",";B1)
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26709
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 3 guests