cancel
Showing results for 
Search instead for 
Did you mean: 

OnBase API Exam: Automation using VB Scripts

Terry_Vantreese
Champ in-the-making
Champ in-the-making
' My questions are in the comments.
' Sometimes I like to avoid creating unnecessary variables if I can easily access information that already exists.
 
Sub Main35()
Dim oApplication = CreateObject("OnBase.Application")
Dim lKeyCount
lKeyCount = oApplication.CurrentDocument.Keywords.Count 'Will this work?
 
Dim sMessage
Dim oKeyword
Dim lLoop
For lLoop = 0 to lKeyCount - 1
    Set oKeyword = oApplication.CurrentDocument.Keywords.Item(lLoop) 'Can I do this?
    sMessage = sMessage & oKeyword.Name & " = " & oKeyword.Value & vbNewline
End For
 
MsgBox sMessage, vbInformation + vbOKonly, "Returned Keywords from Document " & oApplication.CurrentDocument.Handle
 
End Sub
3 REPLIES 3

Not applicable

Yes and yes.  Usually people will dimension lower level objects to make the legwork of the code shorter, but you can absolutely dig into your application object in that way and still get the same results.  I prefer it because it limits the number of lines of code to consider, just a personal thing.

Not applicable

My answer was above, I forgot to make my last post a suggested answer.

Terry_Vantreese
Champ in-the-making
Champ in-the-making

Thanks,

Sometimes it's just 1 line of code that needs access to an object property.