The sample function below shows how to answer prompt using Strategy Office API. Please refer to TN 30086 for generating prompt answers in XML format using Strategy Office 8.1.X.
Sub Button_Answer_Prompt()
Dim PSName, prjName, reportID As String
Dim report As report
Dim reportLocation As reportLocation
Dim prompts As prompts
Dim status As EnumMOIErrorStatus
Dim answerString As String
Dim filesys, text, readfile, contents
PSName = "localhost"
prjName = "Strategy Tutorial"
reportID = "12444C0740283CD5F0923F8F8E3D0A97"
'You must call initialize if you create the report object yourself
'If you get the report object by browsing or finding objects, then the report
'will already be initialized.
Set report = New report
report.Initialize PSName, EnumMWSAuthMode_MWSStandard, prjName, "Administrator", "", reportID, "", status
Set fso = CreateObject("Scripting.FileSystemObject")
Set readfile = fso.OpenTextFile("c:\temp\PromptAnswerXML.xml", 1, False, -1)
answerString = readfile.ReadAll
If status = EnumMOIErrorStatus_MOISuccess Then
'Pass the answerString to the following call.
report.ExecuteAndDisplayInExcel True, answerString, "test", "A1", False, True, EnumMOIDisplayType_MOIDisplayGrid, False, False, reportLocation, prompts, status
If status <> EnumMOIErrorStatus_MOISuccess Then
MsgBox "error", vbInformation, "error"
End If
End If
End Sub
Customization Warning:
This customization is provided as a convenience to Strategy users and is only directly applicable to the version stated. While this code may apply to other releases directly, Strategy Technical Support makes no guarantees that the code provided will apply to any future or previous builds. In the event of a code change in future builds, Strategy Technical Support makes no guarantee that an updated version of this particular customization will be provided. For enhancements to this customization or to incorporate similar functionality into other versions, contact your Account Executive to inquire about Strategy Consulting assistance.
30089