Chapter 5 API Reference

Objects

PTReport Object

Represents the PTReportCom. PTReport is the main class for report generation using PTReportCom.

Using the PTReport Object

The following example creates a PTReport object in another application and then generates a report using a PTR file.

Dim ptrpt As PTReport
Set ptrpt = New PTReport
ptrpt.PPTReport pptApp, "customer_list.ptr"

Methods

FixTableReport Method

Generates a fixed table report based on a template. In a fixed table report, the number of rows and columns is fixed. PTReportCom gets data from a recordset object, and directly fills data into the cells of a table.

Syntax

object.FixTableReport(Recordset, Slide, Table, CellList, Range, FillOrder, ImageList)

object  Required. The object is the PTReport object.

Recordset  Required. An object variable that represents the ADODB.Recordset object to provides data. Before calling this method, please keep the current record position to the first record.

Slide  Required. An object variable that represents the PowerPoint.Slide object to be filled data. Returns the last slide processed.

Table  Required. An integer that represents the index number of the table. The index number starts at 1.

CellList  Required. A string that represents the list of cells separated by the "," character. For example, "A2,B2,B3,D2,D3". The cells in the CellList should correspond to the data source fields in the recordset. The value of the first field is put into the first cell, and the value of the second field is put into the second cell ......

Range  Optional. A string that indicates the range in the table to be used for the records. PTReportCom will skip the range for each record. A range is composed of some rows or columns. You can reference a range of cells like "2:4" or "B:D". The default range is the area that includes all cells for the records.

FillOrder  Optional. An integer that indicates the order in which PTReportCom fills data. If the value is zero, fills data by rows. Otherwise fills data by columns. Default is 0.

ImageList   Optional. A string that indicates which data source fields are the picture files. The ImageList is the list of data source fields separated by the "," character. You can identify a field using the name of field or the index number of field, but not simultaneously. In data source, you stored the path and file name of the picture, not the picture. The file path can be a relative path, an absolute path or a URL. If it is a relative path, the base path is the path of the presentation.

Example

This example uses FixTableReport method to make the report "Top 5 Employees for Sales".

1. Create the template in Microsoft PowerPoint.

PowerPoint Report Template - Top N Employees for Sales

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 TOP 5 e.FirstName + ' ' + e.LastName, SUM(d.Quantity),
	    Sum(d.UnitPrice * d.Quantity * (1-d.Discount)) AS SalesAmount,
	    SalesAmount / (SELECT amount FROM tmp_amount) 
	    FROM Orders o, OrderDetails d, Products p, Employees e 
	    WHERE o.OrderID = d.OrderID AND d.ProductID = p.ProductID
		AND o.EmployeeID = e.EmployeeID AND YEAR(o.OrderDate) = 1996 
		AND MONTH(o.OrderDate) = 04 
		GROUP BY e.FirstName, e.LastName ORDER BY 3 DESC"
    rec.Open strSQL, con
    ptrpt.FixTableReport Recordset:=rec, Slide:=pptSlide, Table:=1, _
	    CellList:="B2"
    rec.Close

3. Generate the report.

PowerPoint Report Sample - Top N Employees for Sales

VarTableReport Method

Generates a variable table report based on a template. In a variable table report, the number of rows or columns in the table is unfixed, and it is variable as the number of the result records. PTReportCom gets data from a recordset object, inserts some blank rows/columns or insert new slide for some records, then fills data into the cells of a table.

Syntax

object.VarTableReport(Recordset, Slide, Table, CellList, Range, Reserve, FillOrder, ImageList, PageBreak, NoData)

object  Required. The object is the PTReport object.

Recordset  Required. An object variable that represents the ADODB.Recordset object to provides data. Before calling this method, please keep the current record position to the first record.

Slide  Required. An object variable that represents the PowerPoint.Slide object to be filled data. Returns the last slide processed.

Table  Required. An integer that represents the index number of the table. The index number starts at 1.

CellList  Required. A string that represents the list of cells separated by the "," character. For example, "A2,B2,B3,D2,D3". The cells in the CellList should correspond to the data source fields in the recordset. The value of the first field is put into the first cell, and the value of the second field is put into the second cell ......

Range  Optional. A string that indicates the range in the table to be used for the records. A range is composed of some rows or columns. You can reference a range of cells like "2:4" or "B:D". PTReportCom will insert some rows/columns for each record, or copy slides for some records. If the length of the range is 1 row/column, you need to reserve 1 or 2 rows/columns in one slide. Otherwise you must reserve all blank rows/columns for records in one slide. The default range is the area that includes all cells for the records.

Reserve  Optional. An integer that indicates the number of records for which you reserved some rows/columns in the report template for the report. One means you reserve some rows/columns for one record, and two means some rows/columns for two records. Default is 1. If the length of the range is 1 row/column, you need to reserve 1 or 2 rows/columns in one slide. Otherwise Reserve must be equal to the PageBreak.

FillOrder  Optional. An integer that indicates the order in which PTReportCom fills data. If the value is zero, fills data by rows. Otherwise fills data by columns. Default is 0.

ImageList  Optional. A string that indicates which data source fields are the picture files. The ImageList is the list of data source fields separated by the "," character. You can identify a field using the name of field or the index number of field, but not simultaneously. In data source, you stored the path and file name of the picture, not the picture. The file path can be a relative path, an absolute path or a URL. If it is a relative path, the base path is the path of the presentation.

PageBreak  Optional. A string that indicates the page breaks, and tells PTReportCom to insert new pages in the report. One page is one slide. The unit of page length is r that means record. For example, "6r" or "6" means that PTReportCom will put 6 records per slide. Default is "" that means no page break. If the length of the range is more than 1, PageBreak must be equal to the Reserve.

NoData  Optional. An integer that represents an option when no data are returned from data source. If the value is 1, PTReportCom will delete the range when no data are returned. If the value is 2, it will delete the table. If the value is 3, it will delete the slide. Default is 0. It means to do nothing.

Example

This example uses VarTableReport method to make the report "Customer List".

1. Create the template in Microsoft PowerPoint.

PowerPoint Report Template - Customer List

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
    ptrpt.VarTableReport Recordset:=rec, Slide:=pptSlide, Table:=1, _
	    CellList:="A2", Reserve:=2, PageBreak:="19"
    rec.Close

3. Generate the report.

PowerPoint Report Sample - Customer List

GroupTableReport Method

Generates a variable table report based on a template, and groups data in the report. In a variable table report, the number of rows or columns in the table is unfixed, and it is variable as the number of the result records. PTReportCom gets data from a recordset object, copy the group range for each group, and copy the detail range for each record.

Syntax

object.GroupTableReport(Recordset, Slide, Table, CellList, Range, Reserve, FillOrder, ImageList, PageBreak, NoData, Group1, GroupRange1, ... Group10, GroupRange10)

object  Required. The object is the PTReport object.

Recordset  Required. An object variable that represents the ADODB.Recordset object to provides data. Before calling this method, please keep the current record position to the first record.

Slide  Required. An object variable that represents the PowerPoint.Slide object to be filled data. Returns the last slide processed.

Table  Required. An integer that represents the index number of the table. The index number starts at 1.

CellList  Required. A string that represents the list of cells separated by the "," character. For example, "A2,B2,B3,D2,D3". The cells in the CellList should correspond to the data source fields in the recordset. The value of the first field is put into the first cell, and the value of the second field is put into the second cell ......

Range  Optional. A string that indicates the range in the table to be used for the records. A range is composed of some rows or columns. You can reference a range of cells like "2:4" or "B:D". PTReportCom will insert some rows/columns for each record, or copy slides for some records. If the length of the range is 1 row/column, you need to reserve 1 or 2 rows/columns in one slide. Otherwise you must reserve all blank rows/columns for records in one slide. The default range is the area that includes all cells for the records.

Reserve  Optional. An integer that indicates the number of records for which you reserved some rows/columns in the report template for the report. One means you reserve some rows/columns for one record, and two means some rows/columns for two records. Default is 1. When the grouprange is same as the range of the detail, you can use Reserve to make report. If the length of the range is 1 row/column, you need to reserve 1 or 2 rows/columns in one slide. Otherwise Reserve must be equal to the PageBreak.

FillOrder  Optional. An integer that indicates the order in which PTReportCom fills data. If the value is zero, fills data by rows. Otherwise fills data by columns. Default is 0.

ImageList  Optional. A string that indicates which data source fields are the picture files. The ImageList is the list of data source fields separated by the "," character. You can identify a field using the name of field or the index number of field, but not simultaneously. In data source, you stored the path and file name of the picture, not the picture. The file path can be a relative path, an absolute path or a URL. If it is a relative path, the base path is the path of the presentation.

PageBreak  Optional. A string that indicates the page breaks, and tells PTReportCom to insert new pages in the report. One page is one slide. The unit of page length is r or g. "r" means record, "g1" means group one, "g2" means group two...... For example, "6r" or "6" means that PTReportCom will put 6 records per slide, "1g" means one group per slide, and "1g,6r" means one group or 6 records per slide. Default PTReportCom will not show the group name in the new page. You can add "s" to show them. For example, "1gs,6rs". If the length of the range is more than 1, PageBreak must be equal to the Reserve. If the grouprange is not same as the range of the detail, you must add a pagebreak by group, and the length of the range can not be more then 1 row/column.

NoData  Optional. An integer that represents an option when no data are returned from data source. If the value is 1, PTReportCom will delete the range when no data are returned. If the value is 2, it will delete the table. If the value is 3, it will delete the slide. Default is 0. It means to do nothing.

Group1...Group10  Optional. A string that indicates the group that is the list of data source fields separated by the "," character. You can identify a field using the name of field or the index number of field, but not simultaneously. In one report, there may be up to 10 groups. Notes: the order of groups should be in accordance with the order of ORDER BY clause in the SQL statement.

GroupRange1...GroupRange10  Optional. A string that indicates the range of the group in the table. PTReportCom will repeat the range for each group. The range of the group should contain the range of the details and the area that includes all cells for this group. You reference a group range like "2:4" or "B:D". For example, there are two groups, the range of the group one contains all cells for the group one and the range of the group two, and the range of the group two contains all cells for the group two and the range of the details. The default range is the area that includes all cells for this group and the range or the group range for the lower level group. If the grouprange is not same as the range of the detail, you must add a pagebreak by group, and the length of the range can not be more then 1 row/column.

Example

This example uses GroupTableReport method to make the report "Customer Profile".

1. Create the template in Microsoft PowerPoint.

PowerPoint Report Template - Customer Profile

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 LEFT(CompanyName,1), CompanyName, ContactName,
	    'Phone: ' & Phone, 'Fax: ' & Fax, Address,
	    CityName & ', ' & CountryName, PostalCode
	    FROM Customers, Cities, Countries
	    WHERE Customers.CityCode = Cities.CityCode
	    AND Customers.CountryCode = Cities.CountryCode
	    AND Customers.CountryCode = Countries.CountryCode
	    ORDER BY CompanyName"
    rec.Open strSQL, con
    ptrpt.GroupTableReport Recordset:=rec, Slide:=pptSlide, Table:=1, _
	    CellList:="A2,B3,C3,D3,D4,E3,E4,E5", Range:="2:5", _
	    Group1:="1", Reserve:=5, PageBreak:="5r"
    rec.Close

3. Generate the report.

PowerPoint Report Sample - Customer Profile

FormReport Method

Generates a form report based on a template, and groups data in the report. For a form report, you can put data from data source into shapes or text boxes in the report file. PTReportCom gets data from a recordset object, copy the slide for each record.

Syntax

object.FormReport(Recordset, Slide, CellList, ImageList, NoData, Group1, ... Group10)

object  Required. The object is the PTReport object.

Recordset  Required. An object variable that represents the ADODB.Recordset object to provides data. Before calling this method, please keep the current record position to the first record.

Slide  Required. An object variable that represents the PowerPoint.Slide object to be filled data. If the slide is deleted, returns nothing. Otherwise returns the last slide processed.

CellList  Required. A string that represents the list of shapes or text boxes in a slide separated by the "," character. For example, "ProductName, ProductID, QuantityPerUnit, UnitPrice". The shapes or text boxes in the celllist should correspond to the data source fields in the SQL statement. The value of the first data source field is put into the first object as a text, and the value of the second data source field is put into the second object......You can get the name of the shape or text box using the add-in "name.ppa".

Range  Optional. A string that indicates the range to be used for the records. PTReportCom will repeat the range for each record. A range is defined by a bookmark. You reference a range using a bookmark name. The default range is the group range or the entire document.

ImageList  Optional. A string that indicates which data source fields are the picture files. The ImageList is the list of data source fields separated by the "," character. You can identify a field using the name of field or the index number of field, but not simultaneously. In data source, you stored the path and file name of the picture, not the picture. The file path can be a relative path, an absolute path or a URL. If it is a relative path, the base path is the path of the table.

NoData  Optional. An integer that represents an option when no data are returned from data source. If the value is 1 or 3, PTReportCom will delete the range when no data are returned. Default is 0. It means to do nothing.

Group1...Group10  Optional. A string that indicates the group that is the list of data source fields separated by the "," character. You can identify a field using the name of field or the index number of field, but not simultaneously. In one report, there may be up to 10 groups. Notes: the order of groups should be in accordance with the order of ORDER BY clause in the SQL statement.

Remarks

In FormReport method, there is no Range and PageBreak. It will put only one record per slide.

Example

This example uses FormReport method to make the report "Supplier Profile".

1. Create the template in Microsoft PowerPoint.

PowerPoint Report Template - Supplier Profile

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,CompanyName,ContactName
	    ,ContactTitle,Address,CityName,CountryName
		,PostalCode,Phone,Fax,HomePage
        FROM Suppliers, Countries, Cities
        WHERE Suppliers.CityCode = Cities.CityCode
        AND Suppliers.CountryCode = Cities.CountryCode
        AND Suppliers.CountryCode = Countries.CountryCode
        ORDER BY CompanyName"
    rec.Open strSQL, con
    ptrpt.FormReport Recordset:=rec, Slide:=pptSlide, _
	    CellList:="SlideTitle,Company,ContactName,ContactTitle, _
	    Address,City,Country,PostCode,Phone,Fax,HomePage"
    rec.Close

3. Generate the report.

PowerPoint Report Sample - Supplier Profile

MSGraphChart Method

Generates a chart based on a template using Microsoft Graph. PTReportCom gets data from a recordset object, and fills data into the datasheet of a chart in the report file.

Syntax

object.MSGraphChart(Recordset, Chart, CellList, Range, FillOrder)

object  Required. The object is the PTReport object.

Recordset  Required. An object variable that represents the ADODB.Recordset object to provides data. Before calling this method, please keep the current record position to the first record.

Chart  Required. An object variable that represents the Graph.Chart object.

CellList  Required. A string that represents the list of cells separated by the "," character. For example, "A2,B2,B3,D2,D3". The cells in the CellList should correspond to the data source fields in the recordset. The value of the first field is put into the first cell, and the value of the second field is put into the second cell ...... Note: On the datasheet, the leftmost column and the top row, which are commonly used for legend text or axis labels, are referred to as column 0 (zero) and row 0 (zero).

Range  Optional. A string that indicates the range in the datasheet to be used for the records. PTReportCom will skip the rows/columns of the range for each record. A range is composed of some rows or columns. You can reference a range of cells like "2:4" or "B:D". The default range is the area that includes all cells for the records.

FillOrder  Optional. An integer that indicates the order in which PTReportCom fills data. If the value is zero, fills data by rows. Otherwise fills data by columns. Default is 1.

Example

This example uses MSGraphChart method to make the report "Sales by Categories".

1. Create the template in Microsoft PowerPoint.

The datasheet of the chart defined in the report template:

Data Sheet Template - Sales by Categories

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 c.CategoryName
	    , Sum(d.UnitPrice * d.Quantity * (1-d.Discount))
	    FROM Orders o, OrderDetails d, Products p, Categories c 
	    WHERE o.OrderID = d.OrderID AND d.ProductID = p.ProductID
	    AND p.CategoryID = c.CategoryID AND YEAR(o.OrderDate) = 1996
	    AND MONTH(o.OrderDate) = 04 GROUP BY c.CategoryName
	    ORDER BY c.CategoryName"
    rec.Open strSQL, con
    ptrpt.MSGraphChart Recordset:=rec, Chart:=pptChart, CellList:="A0"
    rec.Close

3. Generate the report.

The datasheet of the chart generated in the report:

Data Sheet Sample - Sales by Categories

The chart generated in the report:

Chart Sample - Sales by Categories

ExcelChart Method

Generates a chart based on a template using Microsoft Excel. PTReportCom gets data from a recordset object, and fills data into the worksheet of a chart in the report file. Before calling this method, please keep the current record position to the first record.

Syntax

object.ExcelChart(Recordset, Workbook, CellList, ReportType, Range, FillOrder)

object  Required. The object is the PTReport object.

Recordset  Required. An object variable that represents the ADODB.Recordset object to provides data. Before calling this method, please keep the current record position to the first record.

Workbook  Required. An object variable that represents the Excel.Workbook object.

CellList  Required. A string that represents the list of cells separated by the "," character. For example, "A2,B2,B3,D2,D3". The cells in the CellList should correspond to the data source fields in the recordset. The value of the first field is put into the first cell, and the value of the second field is put into the second cell ......

ReportType  Optional. An integer that indicates the report type. If the value is zero, PTReportCom will add some blank rows/columns before filling data values into the worksheet of the chart. If the value is one, PTReportCom will directly fill data vales into the worksheet of the chart. Default is 0. When it is a variable table report, you should reserve two rows/columns in the worksheet in the report template, and set the data range of the chart to 2 rows/columns.

Range  Optional. A string that indicates the range in the datasheet to be used for the records. PTReportCom will skip the rows/columns of the range for each record. A range is composed of some rows or columns. You can reference a range of cells like "2:4" or "B:D". The default range is the area that includes all cells for the records.

FillOrder  Optional. An integer that indicates the order in which PTReportCom fills data. If the value is zero, fills data by rows. Otherwise fills data by columns. Default is 0.

Example

This example uses ExcelChart method to make the report "Sales by Categories".

1. Create the template in Microsoft PowerPoint.

The workheet of the chart defined in the report template:

Data Sheet Template - Sales by Categories

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 c.CategoryName
	    , Sum(d.UnitPrice * d.Quantity * (1-d.Discount))
	    FROM Orders o, OrderDetails d, Products p, Categories c 
	    WHERE o.OrderID = d.OrderID AND d.ProductID = p.ProductID
	    AND p.CategoryID = c.CategoryID AND YEAR(o.OrderDate) = 1996
	    AND MONTH(o.OrderDate) = 04 GROUP BY c.CategoryName
	    ORDER BY c.CategoryName"
    rec.Open strSQL, con
    ptrpt.ExcelChart Recordset:=rec, Workbook:=xlWorkbook, CellList:="A2"
    rec.Close

3. Generate the report.

The worksheet of the chart generated in the report:

Data Sheet Sample - Sales by Categories

The chart generated in the report:

Chart Sample - Sales by Categories

PPTReport Method

Generates the reports based on the templates and a PTR file. The PTR file tells PTReportCom how to get data from data sources and how to put data into the reports.

Syntax

object.PPTReport(Application, PtrFile, Param1 ... Param10)

object  Required. The object is the PTReport object.

Application  Required. An object variable that represents the PowerPoint.Application object.

PtrFile  Required. A string that represents the PTR file. You can include a full path.

Param1 ... Param10  Optional. A string that represents the paramters. These parameters have been defined in the PTR file.

Example

This example uses PPTReport method to make the report "Customer List".

1. Create the template customer_list.ppt using Microsoft PowerPoint.

2. Create the PTR file customer_list.ptr using a text editor.

3. Write the code in your application.

    Set pptApp = New PowerPoint.Application
    Set ptrpt = New PTReport
    Call ptrpt.PPTReport(pptApp, "customer_list.ptr")

GetSlideByIndex Method

Returns a PowerPoint.Slide object by using the slide index.

Syntax

object.GetSlideByIndex(Presentaion, Index)

object  Required. The object is the PTReport object.

Presentaion  Required. An object variable that represents the PowerPoint.Presentaion object.

Index  Required. An integer that represents the index of the slide. The index number starts at 1. If the index number is less than 0, it represents the position from the end of presentation. For examples, slide 2 is the second slide in a presentation, slide -1 is the last slide in a presentation.

Example

This example uses GetSlideByIndex method to get the second slide in the presentation.

    Dim pptPres As PowerPoint.Presentaion
    Dim pptSlide As PowerPoint.Slide
    ......
    Set pptSlide = mptrpt.GetSlideByIndex(pptPres, 2)

GetTableInSlide Method

Returns a PowerPoint.Table object by using the table index.

Syntax

object.GetTableInSlide(Slide, Index)

object  Required. The object is the PTReport object.

Slide  Required. An object variable that represents the PowerPoint.Slide object.

Index  Required. An integer that represents the index of the table. The index number starts at 1. For examples, table 2 is the second table in the slide.

Example

This example uses GetTableInSlide method to get the first table in the slide.

    Dim pptSlide As PowerPoint.Slide
    Dim pptTable As PowerPoint.Table
    ......
    Set pptTable = mptrpt.GetTableInSlide(pptSlide, 1)

GetChartInSlide Method

Returns a PowerPoint.OLEFormat object that represents the Microsoft Graph chart or Microsoft Excel chart OLE object.

Syntax

object.GetChartInSlide(Slide, Index)

object  Required. The object is the PTReport object.

Slide  Required. An object variable that represents the PowerPoint.Slide object.

Index  Required. A string that represents the index of the chart. The index number starts at 1. For examples, chart 2 is the second chart in the slide.

Example

This example uses GetChartInSlide method to get the first chart in the presentation.

    Dim pptSlide As PowerPoint.Slide
    Dim pptChartOLE As PowerPoint.OLEFormat
    Dim graChart As Graph.Chart
    Dim xlWorkbook As Excel.Workbook
    ......
    Set pptChartOLE = mptrpt.GetChartInSlide(pptSlide, 1)
    If Left(wdChartOLE.ProgId, 11) = "Excel.Chart" Then
        Set xlWorkbook = pptChartOLE.object
    Else
        Set graChart = pptChartOLE.object
    End If

Events

BeforeConnect Event

Occurs before a connection starts.

Syntax

Private Sub object_BeforeConnect(UserID As String, Password As String, DataSource As String, Connection As ADODB.Connection)

object  The object is the PTReport object.

UserID  A string that represents a user name for the connection.

Password  A string that represents a password for the connection.

DataSource  A string that represents a data source name for the connection.

Connection  The ADODB.Connection object.

Example

Private Sub mptrpt_BeforeConnect(UserID As String, Password As String, _
    DataSource As String, Connection As ADODB.Connection)
    Connection.ConnectionTimeout = 15
    Connection.CursorLocation = adUseClient
End Sub

TemplateOpen Event

Occurs when a template presentation is opened.

Syntax

Private Sub object_TemplateOpen(ByVal Presentaion As PowerPoint.Presentaion)

object  The object is the PTReport object.

Presentaion  An object variable that represents the PowerPoint.Presentaion object to be opened.

Example

Private Sub mptrpt_TemplateOpen(ByVal Presentaion As PowerPoint.Presentaion)
    gstrFileName = Presentaion.FullName
End Sub

ReportComplete Event

Occurs when all report generating process is completed.

Syntax

Private Sub object_ReportComplete(ByVal Presentaion As PowerPoint.Presentaion)

object  The object is the PTReport object.

Presentaion  An object variable that represents the PowerPoint.Presentaion object.

Example

Private Sub mptrpt_ReportComplete(ByVal Presentaion As PowerPoint.Presentaion)
    With Presentation
        ' Close the presentation and do not display the report when get errors
        If mintErrCount > 0 Then
            .Close
        ' Show the presentation if no error
        Else
            .Application.Visible = True
            .NewWindow
        End If
    End With
End Sub

FunctionBeforeExectue Event

Occurs before a function is executed.

Syntax

Private Sub object_FunctionBeforeExectue(ByVal FunctionNo As String, ByVal FunctionType As Integer, ByVal SQLNo As Long, ByVal SQLText As String)

object  The object is the PTReport object.

FunctionNo  A string that represents the label of the function.

FunctionTyp  An integer that represents the type of the function. 0 means ExecSQL function. 2 means Report function. 3 means Chart function.

SQLNo  A long that represents the number of SQL statements.

SQLText  A string that contains the SQL statement.

Example

Private Sub mptrpt_FunctionBeforeExectue(ByVal FunctionNo As String, _
    ByVal FunctionType As Integer, ByVal SQLNo As Long, _
    ByVal SQLText As String)
    frmWait.lblFunctionNo = FunctionNo
    frmWait.lblSQLCount = SQLNo
End Sub

FunctionAfterExectue Event

Occurs after a function is executed.

Syntax

Private Sub object_FunctionAfterExectue(ByVal FunctionNo As String, ByVal FunctionType As Integer, ByVal SQLNo As Long, ByVal ErrObj As ErrObject)

object  The object is the PTReport object.

FunctionNo  A string that represents the label of the function.

FunctionTyp  An integer that represents the type of the function. 0 means ExecSQL function. 2 means Report function. 3 means Chart function.

SQLNo  A long that represents the number of SQL statements.

ErrObj  The Err object.

Example

Private Sub mptrpt_FunctionAfterExectue(ByVal FunctionNo As String, _
    ByVal FunctionType As Integer, ByVal SQLNo As Long, _
    ByVal ErrObj As ErrObject)
    If ErrObj.Number <> 0 Then
        If FunctionType <> 0 Then           'Ignore errors of EXECSQL
            MsgBox ErrObj.Description, vbExclamation, App.ProductName
            mintErrCount = mintErrCount + 1
        End If
    End If
End Sub

FunctionProgress Event

Occurs periodically during a function processing.

Syntax

Private Sub object_FunctionProgress(ByVal Progress As Long, ByVal RecordCount As Long)

object  The object is the PTReport object.

Progress  A long that indicates the number of records that have currently been processed.

RecordCount  A long that indicates the total number of records.

Example

Private Sub mptrpt_FunctionProgress(ByVal Progress As Long, _
    ByVal RecordCount As Long)
    frmWait.lblRecordCnt.Caption = Format(Progress, "#,##0") & _
        " / " & Format(RecordCount, "#,##0")
End Sub

Error Messages

The following table lists the trappable errors for the PTReport Object.

Value Description
-2147221493 The file PtrFileName does not exist.
-2147221492 The file PtrFileName is not a PPTReport file.
-2147221491 Error in reading the file PtrFileName.
-2147221490 Report template file TemplateFileName does not exist.
-2147221489 The report file is not named correctly.
-2147221488 Failed to create the report file ReportFileName.
-2147221487 Failed to open the template file TemplateFileName.
-2147221486 Failed to save the report file.
-2147221485 Failed to save the report file. Not support the file format: FileFormat.
-2147221473 The ADODB.Recordset object is closed.
-2147221453 Syntax error. The table M in slide N does not exist.
-2147221452 Syntax error. The chart M in slide N does not exist.
-2147221451 Syntax error. The silde N does not exist.
-2147221450 The PowerPoint.Slide object is not set.
-2147221449 The Graph.Chart object is not set.
-2147221448 The Excel.Workbook object is not set.
-2147221447 Unable to find the PowerPoint presentation.
-2147221446 Unable to find the Excel chart.
-2147221445 Unable to find the source data worksheet.
-2147221393 Syntax error. There is a lack of the parameter "CELL".
-2147221392 Syntax error. It is not a valid cell "" for the parameter "CELL".
-2147221391 Syntax error. Failed to parse cell list.
-2147221390 Syntax error. Failed to parse cell Cell.
-2147221389 Can not find the shape Shape in the slide N.
-2147221388 Syntax error. Failed to parse cell Cell. The cell Cell is out of the range of the table.
-2147221387 Can not add text in the shape Shape.
-2147221383 The range should be Range.
-2147221382 Syntax error. Failed to parse range Range.
-2147221381 You should add parameter PAGEBREAK or change the value for RESERVE when the length of the range is more then 1 row/column.
-2147221380 The value Reserve for parameter RESERVE must be equal to the value PageBreak for PAGEBREAK when the length of the range is more then 1 row/column.
-2147221379 You should add a pagebreak by record or change the value for RESERVE when the length of the range is more then 1 row/column.
-2147221378 You should add a pagebreak by record when the length of the range is more then 1 row/column.
-2147221377 The value Reserve for parameter RESERVE must be equal to the value PageBreak for PAGEBREAK when the length of the range is more then 1 row/column.
-2147221373 Syntax error. Failed to parse image. Can not find field ImageField in the image list.
-2147221372 Syntax error. Failed to parse image.
-2147221363 Syntax error. Failed to parse group N. Can not find field Field.
-2147221362 Syntax error. Failed to parse group.
-2147221361 The grouprange of group N should be Range.
-2147221360 Syntax error. Failed to parse grouprange.
-2147221359 The length of the range can not be more then 1 row/column when the grouprange is not same as the range of the detail.
-2147221358 You should add a pagebreak by group when the grouprange is not same as the range of the detail.