I'm looking for advice on a little project.
I have an OO Draw .odg file. In the drawing is a square box with eight text boxes. The text boxes are player positions in a game. I want to reference those player position names out of a spreadsheet. That way anyone can simply update the positions in the spreadsheet cells and I only have to open and print the drawing without making hard changes in the drawing. The final rendition of this will have much more data and player positions, but this gets the point across.
I'm assuming this can be done through scripting or OO BASIC but I'm a wee bit rusty in my programming these days.....
I've included the two files.
Thanks,
D. Speirs
Referencing Calc spreadsheet cells in Draw text boxes
Referencing Calc spreadsheet cells in Draw text boxes
- Attachments
-
- Position Names diagram.odg
- Drawing that shows the game layout. The 1A, 1B,. etc would be replaced with player names.
- (9.21 KiB) Downloaded 173 times
-
- Position names.ods
- Spreadsheet that notates the positions and player names. This is where the changes would be made.
- (9.54 KiB) Downloaded 174 times
OpenOffice 4.0.0 on Windows 7 Pro 64-bit
Re: Referencing Calc spreadsheet cells in Draw text boxes
My first tips:
You must associate names to the text boxes for the easiest identification by the "Starbasic+API functions" type macro code. The names will appeared in the Navigator too.
Then you must edit the width of the textboxes. The names have different length. Adjust the width of the textboxes to the maximum length of the names.
And finally here is a code snippet for set the text content of the named textboxes:
You must associate names to the text boxes for the easiest identification by the "Starbasic+API functions" type macro code. The names will appeared in the Navigator too.
Then you must edit the width of the textboxes. The names have different length. Adjust the width of the textboxes to the maximum length of the names.
And finally here is a code snippet for set the text content of the named textboxes:
Code: Select all
Sub SetNamedShapeTextInCurrentPage(ShapeName as string, ShapeText as String)
Dim oDrawDoc, oDrawPage as object
Dim oShape as object
Dim j as integer
oDrawDoc = Thiscomponent()
oDrawPage = oDrawDoc.GetCurrentController.GetCurrentPage
For j = 0 To oDrawPage.getCount()-1
oShape = oDrawPage.getByIndex(j)
If oShape.GetName() = ShapeName then
oShape.SetString(ShapeText)
end if
Next j
End Sub
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.
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.