开发者

VBA - grabbing column names from lotus notes database using getColumnNames method

So I have a view (object name is 'view') in a Lotus Domino db from which I want to grab the column names and put them in an array:

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

These declarations work fine, but when I try to assign those values to an array using the method called 'getColumnNames', the VBA editor tells me that the method is not supported for that object开发者_Go百科:

Dim someArray() As String

//I tried both of the following with no sucess...

someArray = view.getColumnNames 

someArray() = view.getColumnNames 

What am I doing wrong?


I think you can do a For..Each with columns

dim 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


According to the 8.0 help files, the getColumnNames method is not supported in COM/OLE. However, the attribute ColumnNames is supported. This is VB code from the Help file:

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜