|
-
Sep 19th, 2003, 09:32 AM
#1
Thread Starter
Fanatic Member
Invoking Crystal From VB How?
Thanks in advance to all!
Would appreciate a quick response...
Thanks
-
Sep 19th, 2003, 12:28 PM
#2
Add these references to to your project.
"Crystal Reports x.x ActiveX Designer Runtime Library"
"Crystal Data Object"
"Crystal Reports Expert"
"Crystal Reports x.x Library"
Then something like this to open the report and export the report as a .pdf file.
VB Code:
Option Explicit
Private Function SendReport(ByVal sWhere As String)
Dim oReport As CRAXDRT.Report
Dim crxApplication As New CRAXDRT.Application
Dim crxExportOptions As CRAXDRT.ExportOptions
Set crxApplication = New CRAXDRT.Application
Set oReport = crxApplication.OpenReport(App.Path & "\Report.rpt", 1)
oReport.RecordSelectionFormula = sWhere
Set crxExportOptions = oReport.ExportOptions
crxExportOptions.DestinationType = crEDTDiskFile
crxExportOptions.DiskFileName = App.Path & "Report " & Format(Now, "YYYY-MM-DD") & ".pdf"
crxExportOptions.FormatType = crEFTPortableDocFormat
crxExportOptions.PDFFirstPageNumber = 1
crxExportOptions.PDFLastPageNumber = 1
crxExportOptions.PDFExportAllPages = True
oReport.Export False
'Terminate Cleanly
Set oReport = Nothing
Set crxApplication = Nothing
Set crxExportOptions = Nothing
End Function
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 19th, 2003, 01:16 PM
#3
Thread Starter
Fanatic Member
Mille merci(s)
Thanks a mil...
The .pdf is created in the path of the application...
which I later opened
Any way to open on the fly?
-
Sep 19th, 2003, 01:18 PM
#4
I suppose your could after the termination code use the file name
and shell Acrobat Reader with the file name as a parameter.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 19th, 2003, 01:19 PM
#5
Thread Starter
Fanatic Member
-
Sep 22nd, 2003, 02:31 PM
#6
Thread Starter
Fanatic Member
...me again>
I am shelling acrobar reader...
I don't see the .pdf on the screen...
I have to go to the taskbar ang maximize... it to see it at all
Any ideas? Can't I just pop it on top?
Thanks in advance...
-
Sep 22nd, 2003, 02:49 PM
#7
To shell Acrobat or program associated with the .pdf extension use...
VB Code:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, _
ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Const SW_SHOWNORMAL As Long = 1
Const SW_SHOWMAXIMIZED As Long = 3
Const SW_SHOWMINIMIZED As Long = 2
Private Sub cmdShellPDF_Click()
'WITH THE YOU CAN SET THE WORKING DIRECTORY TOO!
ShellExecute Me.hwnd, vbNullString, "D:\Test.pdf", vbNullString, "D:\", SW_SHOWMAXIMIZED
End Sub
Let me know if this was what you were describing.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 22nd, 2003, 03:18 PM
#8
Thread Starter
Fanatic Member
-
Sep 22nd, 2003, 03:25 PM
#9
Your welcome.
Glad to help.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 24th, 2003, 10:16 AM
#10
Thread Starter
Fanatic Member
one q
I have a table with two fields ActivityDate and Event
How do I pass a parameter to the crystal report so that
it displays events not greater than x number of days old only..
Currently, the report is showing all events
Thanks
-
Sep 24th, 2003, 10:27 AM
#11
Use the parameterfields of the oReport object. You need to clear
each parameter before you set a value to it, every time.
Code:
oReport.ParameterFields.Item(1).ClearCurrentValueAndRange
oReport.ParameterFields.Item(1).AddCurrentValue dActivityDate
oReport.ParameterFields.Item(2).ClearCurrentValueAndRange
oReport.ParameterFields.Item(2).AddCurrentValue sEvent
HTH
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 24th, 2003, 11:07 AM
#12
Thread Starter
Fanatic Member
Pls
Bear with me
The report has subreports and is created external to VB
and I am exporting it into .pdf as u showed me and kick acrobat
to display it... Now, it is one of the subreborts for which I need
a parameter field... So the user could be prompted on the fly (if possible) to enter something and corresponding data would be displayed..
Do we add a parameter field to the individual report before
entering as a subreport...
I guess I am asking how does it all tie...together ?
Currently, my main report displays data for all organizations grouping them by OrgID then the subreport displays data just for the orgID being displayed.. But it's displaying all the activities for it since the beginning of time for the ORg.. What I'd like to do is to create a field that the client could enter a number like 30 enter and only last 30 days activity (for example) would be displayed..
I am probably verbose... But that happens when one has little time to do something with a new tool..
Thanks again
-
Sep 25th, 2003, 09:55 AM
#13
Thread Starter
Fanatic Member
Hi
How does one refresh the report data frm within VB?
Thanks
-
Sep 25th, 2003, 10:07 AM
#14
Since the report is exported out as a pdf file, the report can not
be refreshed unless you re-export the report.
You may want to look at using the Crystal Report Viewer control
in VB to allow you to view/export the report in real time.
Although if you are distributing the program ther may be licensing issues.
As far as the previous post, you need to create a parameter at
the main report level. Then link the parameter to the subreport
by reimporting the sub report. This will allow you to pass a
parameter to the report which will inturn go to the sub report.
HTH
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 25th, 2003, 10:11 AM
#15
Thread Starter
Fanatic Member
...As
always...
Thanks..
For the previous post
Even ReExporting does not seem to do it.. I'll check again...
As for the prior post..
I have decided to create stored procedures which accept parameters that populate a table with the data that I need and the report or subreport would then extract from that table..
-
Sep 25th, 2003, 10:23 AM
#16
Thread Starter
Fanatic Member
ok
Actually, the export would work if one opts to not save the data with the report....
Thanks
-
Sep 25th, 2003, 10:24 AM
#17
In Crystal Reports, when you created the report, there is a
setting under File > Options > Reporting tab... called "Save data
withreport" checkbox. Uncheck it and resave your report. Also,
since you have a subreport, under the New Report tab there is
another checkbox to "Reimport subreport subreports when
opening reports". I'm not too sure if that is only for the
development enviroment or if it could affect your results.
HTH
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|