[Solved] Using quotes in macro issue

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
sokolowitzky
Posts: 103
Joined: Mon Sep 15, 2014 7:34 pm

[Solved] Using quotes in macro issue

Post by sokolowitzky »

I need to insert indirect(address()) into some cells in some sheets. If I can not find a solution probably I will use some kind of copy cell into another one.
But before that I would like to learn if what I'm trying to do is technically impossible.

Since quotes are used for strings in macros, OO basic does not let me insert this code below.
I tried to declare even a variable. But no, still no joy. Anyone have any idea?

Code: Select all

Sub Main
Dim ABS as string
ABS = CHAR(34)&"E1"&CHAR(34)
cell=Thiscomponent.Sheets(1).getcellrangebyname("ax1")
cell.string="=INDIRECT(ADDRESS(1;1;;;"+""+ABS+""+"))"
cell.formula=cell.string
End Sub
Last edited by sokolowitzky on Fri Aug 24, 2018 5:25 pm, edited 1 time in total.
Win10-OpenOffice 4.1/LibreOffice 7.4
FJCC
Moderator
Posts: 9280
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Using quotes in macro issue

Post by FJCC »

I'm not entirely sure what you want your formula output to be, but try this

Code: Select all

cell=Thiscomponent.Sheets(1).getcellrangebyname("ax1")
cell.formula= "=INDIRECT(ADDRESS(1;1;1;" & """E1""" & "))" 
Some comments:
It is enough to set the cell.formula, you do not have to also set the cell.string
ABS is the name of a function in Basic. Don't name a variable ABS, it can lead to trouble.
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.
sokolowitzky
Posts: 103
Joined: Mon Sep 15, 2014 7:34 pm

Re: Using quotes in macro issue

Post by sokolowitzky »

I use variable Indirect(address()) a lot for my own tables. But I could not figure out the problem with quote marks.
That answer will help me alot. It works, many thanks.
Win10-OpenOffice 4.1/LibreOffice 7.4
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] Using quotes in macro issue

Post by Villeroy »

You don't have to put quotes around the sheet name.
=INDIRECT(ADDRESS(1;1;;;E1)) works even if the sheet name in E1 contains spaces.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply