Hi,
I'm creating a VB app that will update the picklist of an .rpt file, and then subsequently update the APS with the new .rpt.
My question is will the file index for the .rpt file always be 1 (see the line highlighted red below)? I'm wondering if it's OK to hard code the file index or whether I will need to search for the .rpt file in the Files collection...
Thanks,
rcs
-----begin code-----
Public Function UpdateAPS(szReport As String) As Integer
Dim oSessionManager As New SessionMgr
Dim Sess As EnterpriseSession
Dim IStore As InfoStore
Dim cReports As InfoObjects
Dim oReportToUpdate As InfoObject
Dim cFileInfo As Files
Dim oFileToUpdate As File
Dim szName As String
Set oSessionManager = CreateObject("CrystalEnterprise.SessionMgr"
Set Sess = oSessionManager.Logon("username", "", "servername", "secEnterprise"
Set IStore = Sess.Service("", "InfoStore"
Set cReports = IStore.Query("SELECT SI_FILES FROM CI_INFOOBJECTS WHERE SI_PROGID = 'CrystalEnterprise.Report' AND SI_NAME = '" & szReport & "'"
Set oReportToUpdate = cReports.Item(1)
Set cFileInfo = oReportToUpdate.Files
Set oFileToUpdate = cFileInfo.Item(1)
szName = oFileToUpdate.Name
MsgBox szName & " will be the file to be updated." & vbCrLf & "There are " & CStr(cFileInfo.Count) & " file(s) associated with this report."
.
.
.
End Function
-----end code-----
I'm creating a VB app that will update the picklist of an .rpt file, and then subsequently update the APS with the new .rpt.
My question is will the file index for the .rpt file always be 1 (see the line highlighted red below)? I'm wondering if it's OK to hard code the file index or whether I will need to search for the .rpt file in the Files collection...
Thanks,
rcs
-----begin code-----
Public Function UpdateAPS(szReport As String) As Integer
Dim oSessionManager As New SessionMgr
Dim Sess As EnterpriseSession
Dim IStore As InfoStore
Dim cReports As InfoObjects
Dim oReportToUpdate As InfoObject
Dim cFileInfo As Files
Dim oFileToUpdate As File
Dim szName As String
Set oSessionManager = CreateObject("CrystalEnterprise.SessionMgr"
Set Sess = oSessionManager.Logon("username", "", "servername", "secEnterprise"
Set IStore = Sess.Service("", "InfoStore"
Set cReports = IStore.Query("SELECT SI_FILES FROM CI_INFOOBJECTS WHERE SI_PROGID = 'CrystalEnterprise.Report' AND SI_NAME = '" & szReport & "'"
Set oReportToUpdate = cReports.Item(1)
Set cFileInfo = oReportToUpdate.Files
Set oFileToUpdate = cFileInfo.Item(1)
szName = oFileToUpdate.Name
MsgBox szName & " will be the file to be updated." & vbCrLf & "There are " & CStr(cFileInfo.Count) & " file(s) associated with this report."
.
.
.
End Function
-----end code-----