Bug 127042 - Unable to modify TablecolumnSeparator in Writer using VB OOO
Summary: Unable to modify TablecolumnSeparator in Writer using VB OOO
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
Version:
(earliest affected)
6.3.0.4 release
Hardware: All Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-20 05:58 UTC by Didier Laroche
Modified: 2019-08-25 08:21 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Writer with working macro (10.75 KB, application/vnd.oasis.opendocument.text)
2019-08-20 05:59 UTC, Didier Laroche
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Didier Laroche 2019-08-20 05:58:25 UTC
Description:
Hello,

I am using VBA (from MS Access) to generate writer documnet.

When dealing with tables, i am unable to modify the TableColumnSepartor property from VB OOO. Same functionality implemented as a Macro in the writer document is working. (document is attached)

My VB ooo code:
Sub ResizeColumnTable()
Dim oSM                   'Root object for accessing OpenOffice from VB
Dim oDesk, oDoc As Object 'First objects from the API
Dim arg()

    'Instantiate OOo
    Set oSM = CreateObject("com.sun.star.ServiceManager")
    ' Create the first and most important service
    Set oDesk = oSM.CreateInstance("com.sun.star.frame.Desktop")
  
    
    ' file must be full access to the file to be uploaded
    Set oDoc = oDesk.loadComponentFromURL("file:///c:/.../bugColumnSeparator.odt", "_blank", 0, arg())
    
    ' ++++++++++++++++++++++++++ table management ++++++++++++++
    Dim oRepTables As Object
    Set oRepTables = oDoc.getTextTables
    
    Dim oTableRep As Object
    Set oTableRep = oRepTables.GetByName("tbl_table1")
    
    ' modify table column separator
    Dim objColumnSeparator As Object
     
    objColumnSeparator = oTableRep.GetPropertyValue("TableColumnSeparators")
    
    objColumnSeparator(0).Position = 1000
    objColumnSeparator(1).Position = 2000
    objColumnSeparator(2).Position = 3000
    objColumnSeparator(2).Position = 4000
    
    
    oTableRep.SetPropertyValue "TableColumnSeparators", objColumnSeparator
     
    'Save the document as a new document
    Call oDoc.storeToURL("file:///c:/...../bugColumnSeparatorUpdated.odt", arg())
    
    'Close the document
    oDoc.Close (True)
    Set oDoc = Nothing
End Sub

I have attached the writer document that contains the same functionality developped as a macro (main)

Steps to Reproduce:
1.run the VB code provided in the description
2.file will not have the column sized modified
3.running macro in the writer document make it work

Actual Results:
table columns are not changed in size

Expected Results:
table column sized changed (same as the main macro in the attached document)


Reproducible: Always


User Profile Reset: Yes



Additional Info:
Sub ResizeColumnTable()
Dim oSM                   'Root object for accessing OpenOffice from VB
Dim oDesk, oDoc As Object 'First objects from the API
Dim arg()

    'Instantiate OOo
    Set oSM = CreateObject("com.sun.star.ServiceManager")
    ' Create the first and most important service
    Set oDesk = oSM.CreateInstance("com.sun.star.frame.Desktop")
  
    
    ' file must be full access to the file to be uploaded
    Set oDoc = oDesk.loadComponentFromURL("file:///c:/.../bugColumnSeparator.odt", "_blank", 0, arg())
    
    ' ++++++++++++++++++++++++++ table management ++++++++++++++
    Dim oRepTables As Object
    Set oRepTables = oDoc.getTextTables
    
    Dim oTableRep As Object
    Set oTableRep = oRepTables.GetByName("tbl_table1")
    
    ' modify table column separator
    Dim objColumnSeparator As Object
     
    objColumnSeparator = oTableRep.GetPropertyValue("TableColumnSeparators")
    
    objColumnSeparator(0).Position = 1000
    objColumnSeparator(1).Position = 2000
    objColumnSeparator(2).Position = 3000
    objColumnSeparator(2).Position = 4000
    
    
    oTableRep.SetPropertyValue "TableColumnSeparators", objColumnSeparator
     
    'Save the document as a new document
    Call oDoc.storeToURL("file:///c:/...../bugColumnSeparatorUpdated.odt", arg())
    
    'Close the document
    oDoc.Close (True)
    Set oDoc = Nothing
End Sub
Comment 1 Didier Laroche 2019-08-20 05:59:35 UTC
Created attachment 153529 [details]
Writer with working macro
Comment 2 Oliver Brinzing 2019-08-23 14:43:09 UTC
it works for me woth LO 6.3.0.4 if i use:
  oTableRep.TableColumnSeparators = objColumnSeparator
instead of:
  oTableRep.SetPropertyValue "TableColumnSeparators", objColumnSeparator


Sub Main()
	Dim arg()

	Set oSM = CreateObject("com.sun.star.ServiceManager")
	Set oDesk = oSM.CreateInstance("com.sun.star.frame.Desktop")
	Set oDoc = oDesk.loadComponentFromURL("file:///d:/downloads/BugTablecolumnSeparator.odt", "_blank", 0, arg)

	Set oRepTables = oDoc.getTextTables

	Set oTableRep = oRepTables.GetByName("tbl_table1")
	objColumnSeparator = oTableRep.GetPropertyValue("TableColumnSeparators")

	objColumnSeparator(0).Position = 1000
	objColumnSeparator(1).Position = 2000
	objColumnSeparator(2).Position = 3000
	objColumnSeparator(3).Position = 4000

	oTableRep.TableColumnSeparators =  objColumnSeparator
'	oTableRep.SetPropertyValue "TableColumnSeparators", objColumnSeparator

	MsgBox "..."
	oDoc.Close (True)
	Set oDoc = Nothing
End Sub
Comment 3 Didier Laroche 2019-08-25 08:21:43 UTC
Hello,

Thanks for your answer. 

I did not test that before posting the bug with version 6.3.0.4. I have just tested it and it works.

Closing the issue now.

Regards,
Didier