[Solved] Formatting Cell with VB

Creating a macro - Writing a Script - Using the API

[Solved] Formatting Cell with VB

Postby moisex » Thu Jul 27, 2017 7:20 am

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   Expand viewCollapse view
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
moisex
 
Posts: 2
Joined: Thu Jul 27, 2017 7:14 am

Re: Formatting Cell with VB

Postby Villeroy » Thu Jul 27, 2017 12:02 pm

Code: Select all   Expand viewCollapse view
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 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 24668
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Formatting Cell with VB

Postby Zizi64 » Thu Jul 27, 2017 3:12 pm

Code: Select all   Expand viewCollapse view
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; LO4.4.7, LO5.3.7 on Win7x64Prof.
PortableApps, WinPenPack: LO3.3.0-LO5.4.3 and AOO4.1.4
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 6087
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Formatting Cell with VB

Postby moisex » Fri Jul 28, 2017 3:54 am

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
moisex
 
Posts: 2
Joined: Thu Jul 27, 2017 7:14 am

Re: Formatting Cell with VB

Postby Zizi64 » Fri Jul 28, 2017 7:13 am

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; LO4.4.7, LO5.3.7 on Win7x64Prof.
PortableApps, WinPenPack: LO3.3.0-LO5.4.3 and AOO4.1.4
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 6087
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Formatting Cell with VB

Postby Villeroy » Fri Jul 28, 2017 11:49 am

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 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 24668
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 11 guests