| Chapter 3 Quick Start |
You can teach yourself how to use WDReportCom by choosing from the methods available in this section:
WDReportCom comes with Sample.mdb, a sample database you can use when learning the program. Sample.mdb is a Microsoft Access database. Virtually all of the examples in this manual are based on Sample.mdb data.
The sample reports access the sample database through the ODBC data source name "Report Sample'. When you install WDReportCom, you can choose to add the ODBC data source name. And you also can add the ODBC data source name manually.
To create the System DSN "Report Sample", do as follows:
1. Click the Windows Start button, choose Settings, and then click Control Panel.
2. On computers running Microsoft Windows 2000 or later, double-click Administrative Tools, and then double-click Data Sources (ODBC). The ODBC Data Source Administrator dialog box appears. On computers running previous versions of Microsoft Windows, double-click 32-bit ODBC or ODBC.
3. Select the System DSN tab, and then press Add button.
4. Choose Microsoft Access Driver (*.mdb), then press Finish button.
5. In the ODBC Microsoft Access Setup dialog box, type Report Sample in the Data Source Name box.
6. Press the Select button, and browse to select Sample.mdb.
7. Press OK button to close the ODBC Microsoft Access Setup dialog box.
8. Press OK button to close the ODBC Data Source Administrator dialog box.
After WDReportCom is installed, some samples are installed too. Use these samples to learn WDReportCom.
The samples include a sample database, VB sample programs, VBA sample programs and sample reports. They are located in the Application Data\LJZsoft under All Users or your profile folder.
| Directory | Description |
| {data}\Common\SampleDatabase | Contains the sample database "Sample.mdb". |
| {data}\WDReportCom\Samples\WordReport | Contains the report template files (.doc) and the WRF files (.wrf). |
| {data}\WDReportCom\Samples\VB | Contains the sample programs for VB6.0. |
| {data}\WDReportCom\Samples\VBA | Contains the sample programs for Microsoft Word VBA. |
{data} is the path of the data folder. You can select the data folder when you install WDReportCom. By default, the data folder is the Application Data\LJZsoft folder under All Users. If you install WDReportCom without administrative privileges, the data folder is the Application Data\LJZsoft folder under the current user. The data folder is usually at:
Windows 95/98: C:\windows\All Users\Application Data\LJZsoft
Windows NT: C:\WinNT\Profiles\All Users\Application Data\LJZsoft
Windows 2000/XP: C:\Documents and Settings\All Users\Application Data\LJZsoft
Windows Vista: C:\ProgramData\LJZsoft
1. Create a template
In Microsoft Word, create a report template file named "custlist.doc". Static values and any Excel features included in the template will be included in the generated report. The template file you have created as follows:
2. Write the code in your application.
Set con = New ADODB.Connection
Set rec = New ADODB.Recordset
con.ConnectionString = "Data Source=Report Sample"
con.Open
strSQL = "SELECT CompanyName, CityName, CountryName, ContactName
FROM Customers, Cities, Countries
WHERE Customers.CityCode = Cities.CityCode
AND Customers.CountryCode = Cities.CountryCode
AND Customers.CountryCode = Countries.CountryCode
ORDER BY CompanyName, CityName, CountryName"
rec.Open strSQL, con
wdrpt.VarTableReport Recordset:=rec, Table:=wdTable, CellList:="A2", Reserve:=2
rec.Close
1. Create a template
In Microsoft Word, create a report template file named "custlist.doc". Static values and any Excel features included in the template will be included in the generated report. The template file you have created as follows:
2. Create a WRF file
Create a WRF file named "custlist.wrf" using WDReportGen or a text editor. The following is the content of the WRF file.
WordReport Version 2.0 [Data Source] Name1=Report Sample [File] ReportTemplateFileName=custlist.doc ReportFileName=Report\custlist.doc LogFileName=Log\custlist.log [SQL] @F1=Report(table=1 cell=A2 reserve=2) SELECT CompanyName ,CityName ,CountryName ,ContactName FROM Customers, Cities, Countries WHERE Customers.CityCode = Cities.CityCode AND Customers.CountryCode = Cities.CountryCode AND Customers.CountryCode = Countries.CountryCode ORDER BY CompanyName,CityName,CountryName
3. Run WordReport.exe
wordreport c:\report\custlist.wrf