VBA - 使用 getColumnNames 方法从 Lotus Notes 数据库中获取列名称

发布于 2024-09-09 03:36:00 字数 530 浏览 10 评论 0原文

因此,我在 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 

我做错了什么?

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:

Dim someArray() As String

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

someArray = view.getColumnNames 

someArray() = view.getColumnNames 

What am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

颜漓半夏 2024-09-16 03:36:00

我认为你可以用列来做一个 For..Each

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

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
红颜悴 2024-09-16 03:36:00

根据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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文