Hello,All!
I want to put the default value in the user prompt,and though to insert code in “Document_BeforeRefresh” event.
There is any way to perform this?What fanction I need for get the user Prompt?
Thank you.
This is what we use in our reports. It will default selected prompts if there is no previously chosen valuables saved with the document.
Private Sub Document_BeforeRefresh(Cancel As Boolean)
'Previously chosen prompt values are stored in variables at the document level.
'This routine sets defaults if the prompts have no previously chosen value.
'Look at the first character of prompt text (the variable name) and:
' 3 = Scale (default 1000)
' 4 = Cost Center (default ALL)
' 5 = Profit Center (default ALL)
' 6 = Client (default ALL)
Dim Var As Variable
For Each Var In ThisDocument.Variables
If Var.IsUserPrompt = True And Var.Value = "" Then
Select Case Left(Var.Name, 1)
Case "3"
Var.Value = "1000"
Case "4", "5", "6"
Var.Value = "ALL"
End Select
End If
Next Var
End Sub
No problem. We found it a very useful solution to the “you must fill in all prompts” behavior when most users wanted the defaults most of the time anyway.
Even if I add a macro to set the default value of prompts (while sending the reports to BCA) it takes the previously stored values.
When I schedule a document and add a custom macro to it, it asks me for the prompt values. In the macro I am re-setting the prompt values but it still takes the values which were manually entered while sending the report to BCA.
How can I set the default values of prompts in my report.
here is the code I am using
Sub SetPromptValues()
Dim myDoc As Document
Set myDoc = ActiveDocument
myDoc.Variables.Item("Currency").Value = "USD"
Application.Interactive = False
myDoc.Refresh
Application.Interactive = True
End Sub
I’m not a BCA expert, but I think BCA basically works by inserting its own VBA procedures into the document as it’s submitted. Those procedures are run when BCA refreshes the document, so I can easily see the behavior you are describing.
That aside, I must ask a question. If you want currency to be USD, why prompt for currency at all? Then you wouldn’t have to try to override the user’s answer (apparently stored in code for BCA) with more code .
When I schedule the report, I want to set USD as default currency.
But after that users should be able to change the value of currency.
So I have made it a prompt. Now I have to set the value of the default value of this prompt while sending it to BCA.
Moreover, the default value USD is not fixed. It will be picked from a file and set to prompts.
This is where you lose me. Once a document is submitted to BCA, there is no additional user interaction. At the scheduled time, the document is refreshed using the prompts chosen at the time the document was submitted to BCA.
I feel like I’m still missing what you’re trying to achieve.
Let me explain.
When the report is sent to BCA, BCA should refresh the report with USD.
(which for me means all the data in report should be converted to USD)
Now when the user views the report via infoview and refreshes the report, the currency should appear as a prompt where the user can change from USD to EUR (from List of Values) or whatever currency he wants for the report.
I have now written a scheduled macro which will run every night. This macro will refresh the report, set the default prompt values and send the reports to corporate documents.