robleyd wrote:Just out of curiosity, what is the actual problem you are trying to solve? This doesn't sound like the "conventional" use of a spreadsheet
Sub setColor(changed As Object)
Dim sheet As Object
Dim cell As Object
Dim fAccess As Object
Dim sRGB As Long
sheet = ThisComponent.Sheets(changed.cellAddress.sheet)
cell = sheet.getCellByPosition(changed.cellAddress.column,changed.cellAddress.row)
fAccess = CreateUnoService("com.sun.star.sheet.FunctionAccess")
sRGB = fAccess.CallFunction("HEX2DEC", array(cell.String))
cell.CellBackColor = sRGB
End Sub
Interestingly, writing CellBackColor does NOT toss out the style that was set, so a style can be set and persist despite other aspects of a cell changing
sub setColor(cell)
svalue = trim(cell.String)
if left(svalue, 1) = "#" then svalue = right(svalue, len(svalue)-1)
cell.CellBackColor = int("&h" + svalue)
end sub
Edit: Here is example of add-in function: download and double-click the oxt file, accept the installation of the extension, and reboot the office program. In Calc, you have now a new BACKGROUND function under Spreadsheet category : |
hubert lambert wrote:
Edit: Here is example of add-in function: download and double-click the oxt file, accept the installation of the extension, and reboot the office program.
In Calc, you have now a new BACKGROUND function under Spreadsheet category :
hubert lambert wrote:Hi,
The sheet event "Content changed" is the easiest way to achieve this, IMHO. And you could make your code far simpler :
- Code: Select all Expand viewCollapse view
sub setColor(cell)
svalue = trim(cell.String)
if left(svalue, 1) = "#" then svalue = right(svalue, len(svalue)-1)
cell.CellBackColor = int("&h" + svalue)
end sub
value = right(svalue, len(svalue)-1)
cell.CellBackColor = &hD7115F
hubert lambert wrote:Ok, I actually didn't realize it was your first attempt in OpenOffice macro. Nice shot anyway !
hubert lambert wrote:About the documentation, you need to distinguish between the UNO language, an abstract language to communicate with the office program, and the script language (basic, python...) that interfaces with that UNO level....snip...When one writeshe actually uses the UNO service com.sun.star.table.CellProperties. In general beginners get lost here
- Code: Select all Expand viewCollapse view
cell.CellBackColor = &hD7115F
.....snip.....OpenOffice.org_Developers_Guide]Developer's Guide[/url] is sometimes usefull, if you need more details. But the best place to start is the Andrew Pitonyak's books : http://www.pitonyak.org/oo.php.
Regarding the little addin BACKGROUND, it's a really quick example I wrote for this post, over an older one, to illustrate that option. If you were ever interested, I should polish it a little bit more... and take more time to explain it. Btw the oxt file is just a renamed zip file, you can easily see the different pieces.
Several people on the Macros and UNO API forum and here have suggested it is better to do macro programming in a modern language like Python instead of writing in Basic. For example, it is simple to sort data in Python but in Basic one must carefully program that. A problem with Python, I think, is that many of the examples/documentation one can find are for Basic. However, as hubert lambert explained it's the UNO interface which is difficult to understand, and that is the same for both languages.Myndex wrote:Currently working/learning more Python.
OpenOffice → Help → Contents → Macros and ProgrammingMyndex wrote: I could not find a BASIC code reference for instance.
Please provide specific links to the problems you have noted.Myndex wrote:the documentation here is literally all over the place, with links to empty pages, and english links with english summaries that link to pages in various asian languages
MrProgrammer wrote:Please provide specific links to the problems you have noted.
Yes, I see that too. The Firefox browser reports: The image “https://wiki.openoffice.org/w/images/thumb/d/df/Documentation_basicguide_dlg_03.gif/500px-Documentation_basicguide_dlg_03.gif” cannot be displayed because it contains errors. However, I can right-click the image and choose Open Link in New Tab. If I do that, the image appears! Open Link in New Tab also works in Safari.Myndex wrote:Missing images: https://wiki.openoffice.org/wiki/Docume ... ide/Events
Parts of the Wiki seem to be broken. Perhaps you can find the missing information in the Developer's Guide PDF, say starting on page 901.Myndex wrote:BLANK: These are just a few examples:
Myndex wrote:To be honest, it's ideal for what I need it for, and it works well. There is an instability where doing too many UNDOs at a time involving cells with the BACKGROUND function will cause the entire app to crash and terminate unexpectedly, but not really a problem for me. I really do appreciate you providing that as it is saving me a ton of time related to some color and vision theory research I am doing, Thank you again!
Missing images: https://wiki.openoffice.org/wiki/Docume ... ide/Events
Zizi64 wrote:Missing images: https://wiki.openoffice.org/wiki/Docume ... ide/Events
Which images are missing? It appeared two pictures for me on that webpage.
hubert lambert wrote:Myndex wrote:To be honest, it's ideal for what I need it for, and it works well. There is an instability where doing too many UNDOs at a time involving cells with the BACKGROUND function will cause the entire app to crash and terminate unexpectedly, but not really a problem for me. I really do appreciate you providing that as it is saving me a ton of time related to some color and vision theory research I am doing, Thank you again!
Here's a new version of this little extension. The function definition is slightly different, so the first extension need to be removed before installing the new one. If I'm right, the undo problem does no longer occure.
The second parameter could be a hexadecimal value (as string) or a decimal value (as numeric).
Regards.
The images are available but the web page does not display them, perhaps because it is coded incorrectly. Since the page is part of the Wiki, the incorrect coding may be in the posting to the Wiki, or it may be the Wiki-to-webpage converter is faulty.Zizi64 wrote:Which images are missing?
Zizi64 wrote:Win 7 prof x64, Firefox 66.0.5 x64:
0000: 47 49 46 38 39 61 C3 B4 01 09 02 GIF89a.....
Users browsing this forum: No registered users and 32 guests