Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
alesnap111
Contributor
Contributor

Need help with msgbox and macro

I need help if users choose no to prompt a password open the document. Is it possible with this example? 

Thank you

 

Sub DisplayMessage
Answer = MsgBox("Expired",4,"Title")
If (Answer=6) and ActiveDocument.Evaluate("today() - makedate(2019,1,1)") > 0 Then
ActiveDocument.GetApplication.Quit
Else
if (Answer=7) and ActiveDocument.Evaluate("today() - makedate(2019,1,1)") > 0 then
' If No (Answer=7) I would like to prompt a password to open the document...

End If
end if
End Sub

3 Replies
wandererroch
Contributor III
Contributor III

Not sure if this would work but you can use Section Access to limit access to the document without resorting to macros. You would just assign a username and password for users and the application handles the rest.
marcus_sommer

The macro-execution (regardless what is within the macro) could be easily bypassed. Therefore I doubt that's really suitable for what do you want to do. But the already mentioned section access might be a solution for your tasks.

- Marcus

alesnap111
Contributor
Contributor
Author

I already implemented Section Access and set module password, so Users cannot access to properties.

I found a solution to prompt for a password if trial period is expired.

Thank you

 

Sub DisplayMessage()
if ActiveDocument.Evaluate("today() - makedate(2019,1,1)") > 0 then
Answer = MsgBox("Trial period expired",4,"Title")
If (Answer=6) and ActiveDocument.Evaluate("today() - makedate(2019,1,1)") > 0 Then
ActiveDocument.GetApplication.Quit
Else
if (Answer=7) and ActiveDocument.Evaluate("today() - makedate(2019,1,1)") > 0 then
myValue = InputBox("Password?")
if myValue = "MYPASSWORD" then
Msgbox "Welcome Admin"
else
ActiveDocument.GetApplication.Quit
End If
End if
End if
End if
End Sub