Getting macro code from a cell and using it for copy paste

Creating a macro - Writing a Script - Using the API

Getting macro code from a cell and using it for copy paste

Postby sokolowitzky » Fri Sep 14, 2018 4:20 am

Hello there,
I have various spreadsheets, in which copy paste areas are different than each other.
So I need some kind of copy paste maker. I will write name of the file and the area to be copied and the file to be written and area to be pasted.
Like C!= ...\xxx.ods D1= Sheet1.A3:E3 and F1: ...\xxy.ods G1=Sheet2.A6:E5
So this list of files will be processed in loop. But to be able to define a Copy paste area the way that I could find is
at first defining the row in the processor sheet with a loop like this
"for i to 100" CELL1=thiscomponent.sheets(0).getcellbyposition(10, i) CELL2=thiscomponent.sheets(0).getcellbyposition(12, i)

On the cell K1 I've input this: DOC2.Sheets.getByName("S1").getcellrangebyname("a3:c3")
and on the cell L1, i've written this. DOC3.Sheets.getByName("S1").getcellrangebyname("a4:c4")

How can I make a copy paste with the basic codes that I've written into spreadsheet?

CELL1.setdataarray (CELL2.getdataarray())
It seems like what I'm asking is a bit confusing. All I need to know is if I can turn a cell string into a macro code.
If I write this =thiscomponent.sheets.getbyname("E2").getcellrangebyname("F1") into a cell, can I use it as an addtess to another cell?
Code: Select all   Expand viewCollapse view
sub trydis
Dim thing as object
Dim thang as object
Dim ranger1 as string
Dim ranger2 as string
thing.string = ranger1
thang.string = ranger2
thang.setFormulaArray (thing.getFormulaArray())

end sub
Last edited by sokolowitzky on Fri Sep 14, 2018 7:10 am, edited 1 time in total.
Ocasionally; Windows 10 & Open Office 4.1.3//LibreOffice 6.0
Posts: 34
Joined: Mon Sep 15, 2014 7:34 pm

Re: Getting macro code from a cell and using it for copy pas

Postby Zizi64 » Fri Sep 14, 2018 7:07 am

i think, You must pass only the arguments from a cell to a macro, but not a full line of the commands. You can pass the Document URL, the Sheet name, the name of the cell Range to copy "From" or "To". You must use more than one cell for it, or you must manage the passed strings like "Sheet1.A1:B2" by the macro.
Tibor Kovacs, Hungary; LO4.4.7, LO5.4.7 on Win7x64Prof.
PortableApps, winPenPack: LO3.3.0-LO6.1.0 and 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
Posts: 7192
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 11 guests