Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Get inputbox response

Hello all,

How I can I detect the response to an inputbox prompt in a macro? Neither of the inputbox methods below seem to work:

oldtext = ActiveDocument.Evaluate("vBookmarkID")
' t = ActiveDocument.GetApplication.InputBox("Enter Quote ID:",oldtext)
t = InputBox("Enter Quote ID:", "Create Quote Bookmark")
if t = vbCancel then
msgbox("Cancelled")
end if

Thanks!

Gordon

3 Replies
Not applicable
Author

With the VB InputBox (the second one), you can determine if the user clicks Cancel or clicks Ok with a blank input. Use:

Sub Responser
t = inputbox("What is your answer")
if t = False Then
msgbox("Cancel")
ElseIf t = "" Then
msgbox("Blank Response")
Else
msgbox(t)
End If
End Sub


If you don't need an input and you just want the user to click Ok or Cancel, you should use MsgBox instead as that will return a value based on which button was clicked.

Not applicable
Author

Thanks for the reply.

I had just sorted it out with a 'len' test eg

if len(t) = 0 then
msgbox("Cancelled")
else
msgbox("OKed")
end if

Interestingly, using the 'ActiveDocument.GetApplication.InputBox' method, the OK button is not available unless something is entered. This is much better than the native VBS inputbox where 'cancel ' returns a 0 length but so does nothing entered and an 'ok'

Regards,

Gordon

Not applicable
Author

My solution can tell the difference between clicking Cancel and clicking Ok without entering anything. In both cases, len(t) = 0. When a user clicks Cancel, t is false. If they click Ok with a blank entry, t is the empty string, "". It may not matter in your app though.

Disabling Ok until there is an entry is probably a better way to handle it. I tend to use the VB Script versions, because I've used them before. The QlikView versions are probably better from the user's perspective.