オブジェクト変数を配列として扱う
スクリプト例
まず、各個人で複数のDBをプロファイル文書に登録させます。
(プロファイル文書のDBTitle・DBServer・DBFileの各フィールドは
複数値入力可能。)
其の上で、他の文書で登録したDBのリストから、
DBがあるかどうかチェックしたいDBタイトルを選択させます。
チェックされたDBタイトル名を元に、プロファイル文書内で
DBタイトル名と同じ配列位置にあるサーバ名・ファイル名を取得し、
DB自体をDB配列変数にセット。
あとはDB自体からタイトルが取れるかどうかで、
そのDBがあるかどうかをチェックし、メッセージ表示。
(プロファイル文書のDBTitle・DBServer・DBFileの各フィールドは
複数値入力可能。)
其の上で、他の文書で登録したDBのリストから、
DBがあるかどうかチェックしたいDBタイトルを選択させます。
チェックされたDBタイトル名を元に、プロファイル文書内で
DBタイトル名と同じ配列位置にあるサーバ名・ファイル名を取得し、
DB自体をDB配列変数にセット。
あとはDB自体からタイトルが取れるかどうかで、
そのDBがあるかどうかをチェックし、メッセージ表示。
Dim wksp As New NotesUIWorkspace
Dim doc As NotesDocument
'--カレント文書の取得
Set doc = wksp.CurrentDocument.Document
Dim doc As NotesDocument
'--カレント文書の取得
Set doc = wksp.CurrentDocument.Document
Dim session As New NotesSession
'--プロファイル文書の取得
Dim profile As NotesDocument
Set profile = session.CurrentDatabase.GetProfileDocument_
("(SearchDBSetup)", session.UserName)
'--プロファイル文書の取得
Dim profile As NotesDocument
Set profile = session.CurrentDatabase.GetProfileDocument_
("(SearchDBSetup)", session.UserName)
'--DBファイルパスの取得のための配列位置取得
Dim index() As Integer
Dim cnt As Integer
Forall myfile In doc.SearchDB
For i = 0 To Ubound(profile.DBTitle)
If Strcomp(myfile, profile.DBTitle(i), 4) = 0 Then
Redim Preserve index(cnt) As Integer
index(cnt) = i
cnt = cnt + 1
End If
Next
End Forall
Dim index() As Integer
Dim cnt As Integer
Forall myfile In doc.SearchDB
For i = 0 To Ubound(profile.DBTitle)
If Strcomp(myfile, profile.DBTitle(i), 4) = 0 Then
Redim Preserve index(cnt) As Integer
index(cnt) = i
cnt = cnt + 1
End If
Next
End Forall
'--DBの取得
Dim db() As NotesDatabase
Dim errstr as string
For i = 0 To Ubound(index)
Redim Preserve db(i) As NotesDatabase
Set db(i) = session.GetDatabase_
(profile.DBServer(index(i)), profile.DBFile(index(i)))
If db(i).Title = "" Then
If errstr = "" Then
errstr = profile.DBTitle(index(i))
Else
errstr = errstr + Chr(10) + profile.DBTitle(index(i))
End If
End If
Next
Dim db() As NotesDatabase
Dim errstr as string
For i = 0 To Ubound(index)
Redim Preserve db(i) As NotesDatabase
Set db(i) = session.GetDatabase_
(profile.DBServer(index(i)), profile.DBFile(index(i)))
If db(i).Title = "" Then
If errstr = "" Then
errstr = profile.DBTitle(index(i))
Else
errstr = errstr + Chr(10) + profile.DBTitle(index(i))
End If
End If
Next
If errstr <> "" Then
Messagebox "アクセスできない" + Chr(10) + errstr
Exit Sub
End If
Messagebox "アクセスできない" + Chr(10) + errstr
Exit Sub
End If
