所以我在Lotus Domino数据库中有一个视图(对象名称是'view'),我想从中获取列名并将它们放在一个数组中:
Dim view As Domino.NotesView
Set view = db.GetView(viewScen)
//viewScen is a string containing the actual view's name
//db is a string containing the actual db name
这些声明工作正常,但是当我尝试使用名为'getColumnNames'的方法将这些值分配给数组时,VBA编辑器告诉我该对象不支持该方法:
Dim someArray() As String
//I tried both of the following with no sucess...
someArray = view.getColumnNames
someArray() = view.getColumnNames
我做错了什么?
答案 0 :(得分:0)
我认为你可以用列
做一个For..Eachdim idx as integer
dim OneCol as Column
redim someArray(view.Columns.Count)
For idx = 0 to view.Columns.Count - 1
someArray(idx) = view.Columns(idx).name
Next
答案 1 :(得分:0)
根据8.0帮助文件,COM / OLE中不支持getColumnNames方法。但是,支持属性ColumnNames。这是帮助文件中的VB代码:
Private Sub ViewColumnNames_Click()
Dim s As New NotesSession
s.Initialize
Dim dir As NotesDbDirectory
Dim db As NotesDatabase
Dim v As NotesView
Dim cns As String
Set dir = s.GetDbDirectory("")
Set db = dir.OpenDatabase("Web test")
Set v = db.GetView("Main View")
For Each cn In v.ColumnNames
cns = cns + cn + Chr(10)
Next
MsgBox cns, , "Columns in Main View"
End Sub