将数据从listview导出到OpenOffice VB6

将数据从listview导出到OpenOffice VB6,vb6,Vb6,我有一个程序,可以将CSV文件中的数据显示到ListView中。 然后,我有一个名为“Reports”的按钮—当我单击此按钮时,我希望数据显示在OpenOffice Calc中的ListView/CSV文件中 这是我的代码: Private Sub cmdReports_Click() Dim oSM As Object Dim oDesk As Object Dim oDoc As Object Dim oSheet As Object Dim i As Integer 'Instancia

我有一个程序,可以将CSV文件中的数据显示到ListView中。 然后,我有一个名为“Reports”的按钮—当我单击此按钮时,我希望数据显示在OpenOffice Calc中的ListView/CSV文件中

这是我的代码:

Private Sub cmdReports_Click()
Dim oSM As Object
Dim oDesk As Object
Dim oDoc As Object
Dim oSheet As Object
Dim i As Integer

'Instanciate OOo : this line is mandatory with VB for OOo API
Set oSM = CreateObject("com.sun.star.ServiceManage…
'Create the first and most important service
Set oDesk = oSM.CreateInstance("com.sun.star.frame.D…
'Create a new doc
Set oDoc = oDesk.loadComponentFromURL("private:fact… "_blank", _
0, arg())
'Get the first sheet in the doc
Set oSheet = oDoc.getSheets().getByIndex(0)


With oSheet
For i = 1 To ListView1.ListItems.Count
.cells(i, 1) = ListView1.ListItems(i).Text
.cells(i, 2) = ListView1.ListItems(i).SubItems(1)
.cells(i, 3) = ListView1.ListItems(i).SubItems(2)
.cells(i, 4) = ListView1.ListItems(i).SubItems(3)
Next
End With
End Sub
目前,我的所有按钮都在执行给我运行时错误“438”的操作。对象不支持此属性或方法 调试时,此行将突出显示:

.cells(i, 1) = ListView1.ListItems(i).Text
这段代码是为Excel编写的,但我对其进行了编辑,以便可以在OpenOffice Calc中显示。 有人能帮忙吗?
感谢

它的意思正是它所说的-该语句使用了Ole自动化接口不支持的method属性。第一个问题:你能使用一个类型库吗(参见引用对话框-列表中是否有类似OpenOffice Calc的东西)?了解编译时可用的方法和属性要好得多-您可以使用Microsoft Excel执行同样的操作。然后可以将变量声明为特定类型,而不是“作为对象”

由于不了解OpenOffice,我查找了有关OpenOffice的文档,发现了下一个最好的东西,Star Office。尝试:。有关电子表格的文档,请参阅第64页第4.4节。对象模型与Office不同,这可以解释您的问题

看起来您需要使用Sheet.getCellByPosition()方法,而不是Cells()方法,例如

GetCell = oSheet.getCellByPosition (nColumn , nRow)