[Solved] Formatting Cell with VB

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
moisex
Posts: 2
Joined: Thu Jul 27, 2017 7:14 am

[Solved] Formatting Cell with VB

Post by moisex »

I created an application with VS Community in which when a button is pressed takes some data from textboxes and insert them into an OpenOffice Calc, my code is:

Code: Select all

Dim args(-1) As Object
Dim objServiceManager As Object = CreateObject("com.sun.star.ServiceManager")
Dim objDesktop As Object = objServiceManager.createInstance("com.sun.star.frame.Desktop")
Dim objDocument As Object = objDesktop.loadComponentFromURL("private:factory/scalc", "_blank", 0, args)
Dim objSheet As Object = objDocument.Sheets.getByIndex(0)
Dim oCell As Object = objSheet.getCellRangeByName("B4")
oCell.String = "Escrupuloso"
oCell.CellBackColor = RGB(20,140,180)
What I want is to format more properties of the cell, like border, borderwidth, height and width, font, and most importantly combine cells into one
I've searched info but there is almost no info about, I'm stucked at this point because I only found info to write the code from above and nothing else.
I'm a beginner with this, Idk if someone can help me.
Last edited by moisex on Sat Jul 29, 2017 3:17 pm, edited 1 time in total.
OpenOffice 3.1 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Formatting Cell with VB

Post by Villeroy »

Code: Select all

oCell.CellStyle = "your_most_sophisticated_cell_style_with_anything_you want"
http://extensions.openoffice.org/en/pro ... ction-tool
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
User avatar
Zizi64
Volunteer
Posts: 11359
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Formatting Cell with VB

Post by Zizi64 »

Code: Select all

oCell.CellStyle = "your_most_sophisticated_cell_style_with_anything_you want"
+1

...Yes it is better to use the styles (the Cell styles in this case) instead of the direct formatting properties.
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.
moisex
Posts: 2
Joined: Thu Jul 27, 2017 7:14 am

Re: Formatting Cell with VB

Post by moisex »

Thanks, but do you have any info about? I've searched about and got nothing, I don't know if I have to create a new CellStyle programatically.
OpenOffice 3.1 on Windows 10
User avatar
Zizi64
Volunteer
Posts: 11359
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Formatting Cell with VB

Post by Zizi64 »

Andrew Pitonyak's free macro books are the best sources of the programming informations and example codes.

http://www.pitonyak.org/oo.php

And you need study athe desctriptions of the API (Application Programming Interface of the AOO and/or LO.
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.
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Formatting Cell with VB

Post by Villeroy »

moisex wrote:Thanks, but do you have any info about? I've searched about and got nothing, I don't know if I have to create a new CellStyle programatically.
You do not create cell styles programmatically. Being a good programmer you work with templates. This will save you thousands of lines of most stupid coding work.
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