[Dropped] Need some help for Calc macro function

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Ricky
Posts: 14
Joined: Sun Nov 12, 2017 11:39 pm

[Dropped] Need some help for Calc macro function

Post by Ricky »

i started a new calc macro function

and having some problems and need help

first problem is with a for loop

it does read the first value but cannot read the other values function of rows!

Code: Select all

for i = Xrow to xrowmax
		my_cell = ThisComponent.Sheets(0).getCellByPosition( 1  , i )
		com.sun.star.table.CellContentType.VALUE
		cell_value = my_cell.Value

		MsgBox "cell value = " & cell_value
	next i
can someone help to make this loop work as it should !


thanks for feedback
Last edited by MrProgrammer on Sun Dec 24, 2023 2:31 am, edited 2 times in total.
Reason: Dropped: No response from Ricky
Openoffice 3.1 Win 10 64 bits
FJCC
Moderator
Posts: 9277
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Need some help for Calc macro function

Post by FJCC »

I can run your code as a Sub with no problem. This version reads back the first 5 values in column B of the first sheet.

Code: Select all

Sub Main
Xrow=0
xrowmax=4
for i = Xrow to xrowmax


my_cell = ThisComponent.Sheets(0).getCellByPosition( 1 , i )


'com.sun.star.table.CellContentType.VALUE
cell_value = my_cell.Value

MsgBox "cell value = " & cell_value


next i
End Sub
How exactly are you using your code?
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
User avatar
Zizi64
Volunteer
Posts: 11360
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Need some help for Calc macro function

Post by Zizi64 »

A macro Function can modify only the value of that cell, where the function was called.

If you want to modify the values more than one cells, then you must
- create an array Function.
- use the macro as a Subroutine, launched by some user activity or event.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
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.
Post Reply