Dan
Tue Dec 06 15:03:01 CST 2005
Crystal uses collections, you can interate through them to get the names. I
wrote a routine awhile back to read a crystal report and display its
information into my standard toolbox program.
The code was similar to the following:
cFileName = "D:\Acoworks\Dev\Acowin_Source\Reports\CallSlip.rpt"
? Read_CR(cFileName)
PROCEDURE Read_CR
LPARAMETERS cFileName
IF FILE(cFileName)=.f.
MESSAGEBOX("File not found")
RETURN
ENDIF
oCR = CREATEOBJECT("CrystalRuntime.Application")
oRpt = oCR.OpenReport(cFileName)
m_text = ""
crlf = CHR(13)+CHR(10)
m_section_count = oRpt.Sections.Count
FOR m_cnt1 = 1 to m_section_count
oSection = oRpt.Sections.Item(m_cnt1)
m_obj_count = oSection.ReportObjects.count
m_text = m_text + REPLICATE('=',100) + crlf
m_text = m_text + "Section: " + oSection.Name + crlf
FOR m_cnt2 = 1 to m_obj_count
oObject = oSection.ReportObjects.Item(m_cnt2)
clName = oObject.Name
m_text = m_text + "Object: " + PADR(ALLTRIM(STR(m_cnt2)),10) +
PADR(ALLTRIM(clName),20)
do case
case left(upper(clName),4)="TEXT"
m_text = m_text + oObject.text
case left(upper(clName),4)="SUB"
m_text = m_text + oObject.SubReportName
case left(upper(clName),4)="FIEL"
m_text = m_text + oObject.Field.Name
ENDCASE
m_text = m_text + crlf
ENDFOR
m_text = m_text + crlf
ENDFOR
RETURN m_text
ENDPROC
This output is a bit crude, but you can format the information into a nice
user interface.
Hope this helps,
Dan
"Man-wai Chang" <toylet.toylet@gmail.com> wrote in message
news:%23PceLol%23FHA.2300@TK2MSFTNGP10.phx.gbl...
> Michel Roy wrote:
> > the parameterfields is a collection but from the example i saw
> > in vb they did not add a name on creation.
> >
> > you can get the parameter field name with
> > ocParm.Item(1).ParameterFieldName
>
> Thans. Got it working, with the example from Mr. Bernston's site. I
> could only reference them as 1,2,3,4,5... How does CR set the order of
> parameter field? I meant is it a trial-and-error process to find out the
> order from VFP side?
>
> --
> .~. Might, Courage, Vision. Sincerity.
http://www.linux-sxs.org
> / v \
> /( _ )\ (Ubuntu 5.10) Linux 2.6.14.3
> ^ ^ 19:40:02 up 9 days 23:34 load average: 1.85 1.46 1.48