[Solved] Basic Macro Calc Return Row of a Found Cell

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Tom Sequitur
Posts: 14
Joined: Wed Feb 03, 2016 1:50 am

[Solved] Basic Macro Calc Return Row of a Found Cell

Post by Tom Sequitur »

This works, needed declarations elsewhere.

Code: Select all


REM  *****  BASIC  *****

Sub URLchanged

Dim lOK as Boolean

lOk = True

otxtCitationURL = oDlg.getControl("txtCitationURL")  

oSearchCitation.SearchString = otxtCitationURL.Text
oFoundCitation = oCitationSheet.findFirst(oSearchCitation)

If IsNull(oFoundCitation) Then

 MsgBox("No URL found, so you will have to copy and past in the article's information!"
 lOK = False

End If

If lOK Then

  print oFoundCitation.AbsoluteName

End If


End Sub
What I want to do is basically:

Instead of:

print oFoundCitation.AbsoluteName

down in my code, I would like to just get print (actually grab) the sheet, row, and column separately i.e.:

print oFoundCitation.SheetName
print oFoundCitation.RowName (and-or numeric x coordinate)
print oFoundCitation.ColumnName (and-or numeric y coordinate)

I am just not finding this stuff in the Basic Guide or Pitonyak's book.
Last edited by Tom Sequitur on Tue Feb 09, 2016 9:11 pm, edited 1 time in total.
Tom Sequitur
OpenOffice 4.1.1 on LinuxMint 17.2
FJCC
Moderator
Posts: 9274
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Basic Macro Calc Return Row of a Found Cell

Post by FJCC »

You need to get an object inspector like MRI so you can see the properties and methods of you objects.
To see the Sheet, Row and Column of the found cell you can use

Code: Select all

oSheets = ThisComponent.Sheets
oHoja = oSheets.getByName("Hoja1")
Desc = oHoja.createSearchDescriptor()
Desc.SearchString = "This"
oFound = oHoja.findFirst(Desc)
CellAddress = oFound.CellAddress
SpreadSheet = oFound.SpreadSheet
print "Row = " & CellAddress.Row
print "Column = " & CellAddress.Column
print "Sheet Name = " & SpreadSheet.Name
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.
Tom Sequitur
Posts: 14
Joined: Wed Feb 03, 2016 1:50 am

Re: Basic Macro Calc Return Row of a Found Cell [SOLVED]

Post by Tom Sequitur »

FJCC wrote:You need to get an object inspector like MRI so you can see the properties and methods of you objects.
Agreed, as to the object inspector, will try to make MRI work for me.

Your code worked like a champ. Thanks again for the help. I just wish this stuff had better docs. It's pretty hard for a novice to work through.
Tom Sequitur
OpenOffice 4.1.1 on LinuxMint 17.2
Tom Sequitur
Posts: 14
Joined: Wed Feb 03, 2016 1:50 am

Re: Basic Macro Calc Return Row of a Found Cell

Post by Tom Sequitur »

Looking at MRI, it's not very novice friendly either. Not sure how to install and use it but will see if I can get it going.
Tom Sequitur
OpenOffice 4.1.1 on LinuxMint 17.2
FJCC
Moderator
Posts: 9274
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Basic Macro Calc Return Row of a Found Cell

Post by FJCC »

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.
Post Reply