cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to Find/Replace a Keyword Value Using the Keyword Name as the Identifier Using VB

Keith_Malek1
Star Contributor
Star Contributor

Hello All,

I'm trying to find/replace a keyword value using the keyword name as the identifier.
i.e. if keyword name = "Hello" then keyword value = "Hello World".

I can do it by cycling through the keyword position number but unfortunately they can change order.

I've looked all over the forums and through the training doc's that are on here and cant find anything.

Please see code below and let me know if you have any ideas:

Sub FormAppliedMain
Dim objKeywords
Set objKeywords = OCRDoc.Document.Keywords

Dim lngIndex
Dim strKeywordString
Dim poNumber

Do While (lngIndex < objKeywords.Count)

Select Case objKeywords(lngIndex).Value
Case "17-8921-7/15"
if objKeywords(lngIndex).name = "Evidence Type" then
objKeywords(lngIndex).value = "Tim"
else if objKeywords(lngIndex).name = "Language" then
objKeywords(lngIndex).value = "APPLICATION FOR"
end if
End Select

lngIndex = lngIndex + 1

Loop

Call OCRDoc.Document.StoreKeywords()
End Sub

1 ACCEPTED ANSWER

 Could you accomplish this without using scripting, but using the template level or global level keyword lookup and replace rules that are built in to AC?  i.e. 'if keyword type = X and value = Y then replace value with Z' type rules?

View answer in original post

5 REPLIES 5

 Could you accomplish this without using scripting, but using the template level or global level keyword lookup and replace rules that are built in to AC?  i.e. 'if keyword type = X and value = Y then replace value with Z' type rules?

The issue with doing it that way is that keywords are not on the document. ie. if you find that it's form XYZ then these keywords should be these values and it's a case statement so that it can cover multiple documents without having a template for each.

Ah ok. Well I think the issue with your script is that if the keyword type(s) you are looking for in the loop don't have any value (i.e. they are blank) then the objKeywords list won't include them. My suggestion would be to include a Boolean flag that you set to True when you find and update the keyword type(s) in the list that you care about, and then at the end of the loop, if you didn't find one or more of them that you expected to, that would mean they're blank and you could apply them by calling objKeywords.AddKeyword ("type name", "value") before calling StoreKeywords().

That worked. (just without the parentheses)

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.