我有一个程序可以将 CSV 文件中的数据显示到 ListView 中。然后我有一个名为“报告”的按钮 - 当我单击此按钮时,我希望从 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 中显示。有人可以帮忙吗?谢谢