Ask Your Question

newOOo3's profile - activity

2019-01-15 11:25:35 +0200 received badge  Nice Answer (source)
2013-12-24 10:49:07 +0200 answered a question in calc code using optimalWidth for columns is incorrect


I think that the "oColumns = FileList.Columns" is incorrect .
I can not understand "FileList".
I think it is Ok if you change following;
oColumns = FileList.Columns → oColumns = ThisComponent.getsheets().getByIndex(0)

You can see sample code following URL ;

OptimalWidth : 行高さ&列幅の最適化(1) ⇔ Optimize hight of rows and width of columns(1)
.uno:SetOptimalColumnWidth : 行高さ&列幅の最適化(2) ⇔ Optimize hight of rows and width of columns(2)

-------- [ PS ] -------
2th answer write;
>My code ran as does yours and both give the same incorrect result.

I can not understand why both have the same incorrect result.
I think that Code " OptimalWidth : 行高さ&列幅の最適化(1) ⇔ Optimize hight of rows and width of columns(1)" to be optimized all height and width in the sheet without error.

2th answer write;
>・・・simpler code does not get the same result as the UNO code.

I think that following code give exactly the same result as the UNO code

Sub ColRowOptimaize()
    Dim oDoc as Object, oSheet as Object
    Dim oCol as Object, oRow as Object
        oDoc = ThisComponent
        oSheet = oDoc.getSheets().getByIndex(0)
        oCol = oSheet.getColumns().getByIndex(0)
        oCol.OptimalWidth = true
        for i = 0 to 1
            oRow = oSheet.getRows().getByIndex(i)
            oRow.OptimalHeight = true
        next i
    msgbox "Success"
End Sub
2013-11-18 10:39:11 +0200 answered a question LO Basic get current row

Hi, slink9 .

Do you want to know how to get the address of current cell with LibreOffice Basic macro ?
If so, yow use getRangeAddress() or getCellAddress() method.
You can see the sample codes the following URL;

[ Explain ]
Current Cell : A10 in Sheet2 ⇔ (0,9) / Sheet No = 1
getRangeAddress() : Current CellのAddress取得(1) ⇔ Get the address of current cell(1)
getCellAddress() : Current CellのAddress取得(2) ⇔ Get the address of current cell(2)

2013-08-17 16:10:30 +0200 answered a question delete a file on disk using libre office macro

Hi, Vineet .
> wish to delete this csv file from disk ・・・How to do it using macro? (either python or vba or else)
Dose vba means LibreOffice Basic( LO Basic ) ?
If so, you use "kill" on LO Basic.
When you write macro using python, you use "remove" or "kill".
You can see the following URL for the sample code;

[ LO Basic ]
Sample 1( use "" service )
  URL 1:
Sample 2( not use "" service )
  URL 2:

[ Python ]
Sample 1( remove )
  URL 1:
Sample 2( use "" service )
  URL 1:

2013-07-12 12:07:53 +0200 answered a question How can I make two images the same size in Writer?

I recommend that you try to use the following URL extension. It is the extension of Apache OpenOffice, but you can use it probably.

Extention name : FitShape( URL : )

[ way to use ]

  1. When you install the extension,item named FitShape is added to the menu bar
  2. Select some images.( Shift + click )
  3. Click 'FitShape', then you see three commands.
    << Command >>
    • 幅を揃える → Fit width
    • 高さを揃える → Fit hieght
    • 幅と高さを揃える → Fit width and height and height
2013-07-09 13:12:57 +0200 answered a question Python UNO LibreOffice UI scripting

Hi, mipmap.

ok_button_model.PositionX = 50 <- THROWS ERROR

'OK button model.Position X = 50' are correct, but I think Code of the previous line is wrong. This means that I will change as follows

dialog_model = service_manager.createInstanceWithContext("", context)
ok_button_model = service_manager.createInstanceWithContext("", context)
ok_button_model.PositionX = 50 <- THROWS ERROR


oCtx = uno.getComponentContext()
oServiceManager = oCtx.ServiceManager
dialog_model = oServiceManager .createInstance('')
ok_button_model = dialog_model.createInstance('')
ok_button_model.PositionX = 50

I think the code of the following URL would be helpful.

2013-05-09 20:18:17 +0200 received badge  Nice Answer (source)
2013-05-09 12:48:01 +0200 answered a question How to change "ThisComponent"?


I think when you write the macro in Calc Document, " ThisComponent" means Calc document. So, "ThisComponent.supportsService("")" will return false. I guess your correct code mean following ;

Sub Main
Dim oDoc as Object, oText as Object, oInsertText as String
    oDoc = StarDesktop.loadComponentFromURL( "private:factory/swriter", "_blank", 0, Array())
    oText = oDoc.getText()
    oInsrtText = "The quick brown fox jumped over the lazy dogs."
    oText.insertString(oText.getStart(), oInsrtText , false)
End Sub
2013-05-01 18:21:50 +0200 received badge  Teacher (source)
2013-05-01 16:27:40 +0200 answered a question How to test for LO version in Calc macro?


Do you want to know how to get LO Version using macro? If so, you use "GetSolarVersion" or "" / "". However, 4.0.12 will return value as 4.0.0. You can see the following URL for the sample code;

2013-03-24 14:00:29 +0200 received badge  Editor (source)
2013-03-24 13:58:46 +0200 answered a question How can I create a macro to set default margins?

Hi @Uglyface200

I also think the answer of @qubit is good solution.

・・・・,then document templates are a good solution.

As reference, I think the following code is helpful;

[ Properties ] => Top : .TopMargin / Bottom : .BottomMargin / Left : .LeftMargin / Right : RightMargin