PC-DMIS 2019 R2 Object Library
Add Method
See Also  Send Topic Feedback | See Object Hierarchy Chart
PCDLRN ActiveX DLL > ReportTemplates Object : Add Method

Glossary Item Box

Description

The Add function creates a new report template in PC-DMIS.

Syntax

Visual Basic
Public Function Add() As ReportTemplate

Example

Sub Create_Report_Template()

    ' This test subroutine was created to show how report templates can be

    ' automatically generated using PC-DMIS Automation

    ' This was created inside Microsoft Excel

 

     

    ' Make sure PC-DMIS is running

    If MsgBox("This example will use your existing measurement routine and create an automatic Report Template with a title of your choice. Is PC-DMIS running and is your measurement routine loaded?", vbYesNo, "Automated Report Template Creation") = vbNo Then

        MsgBox "Closing this example. Try again once PC-DMIS is running and a measurement routine is loaded.", vbExclamation

        Exit Sub

    End If

    

    ' Create the PC-DMIS Application

    Dim PCDApp As PCDLRN.Application

    Set PCDApp = CreateObject("Pcdlrn.Application")

    

    ' Open a Measurement Routine

    Dim PP As PartProgram

    Set PP = PCDApp.ActivePartProgram

    Dim RepTemplates As ReportTemplates

    Set RepTemplates = PCDApp.ReportTemplates

    Dim RepTemplate As ReportTemplate

    

    ' Add a new Report Template

    Set RepTemplate = RepTemplates.Add

    

    

    ' Use the existing default section of "Section1" for new templates

    Dim Secs As Sections

    Set Secs = RepTemplate.Sections

    Dim Sec1 As Section

    Dim Sec2 As Section

    

    Set Sec1 = RepTemplate.Sections.Item("Section1")

    ' Add a Text object into TestSection1 and define its Text property

    Dim RepControls As ReportControls

    Set RepControls = Sec1.ReportControls

    Dim strReportTitle As String

    strReportTitle = InputBox("Please type a title for your report that's less than 30 characters", "Report Title")

    If Len(strReportTitle) > 30 Then

        MsgBox "Length is more than 30 chars. Your report title may need some adjusting later.", vbInformation

    End If

    

    Set TextObj = Sec1.ReportControls.Add(ID_HOB_TEXT, 50, 50, 750, 100)

    TextObj.Font = 36

    TextObj.Alignment = 1 ' To center it

    TextObj.BackColor = RGB(128, 0, 64)

    TextObj.ForeColor = RGB(255, 255, 255)

    TextObj.Text = strReportTitle

        

    Sec1.ReportControls.Add ID_HOB_PCD_TEXT_REPORT_OBJECT, 50, 170, 750, 930

    

    ' Add a new Section named "TestSection2"

    Set Sec2 = RepTemplate.Sections.Add("MySection2")

    

    ' Add some objects into TestSection2

    Set TextObj2 = Sec2.ReportControls.Add(ID_HOB_TEXT, 50, 50, 750, 100)

    TextObj2.Font = 24

    TextObj2.Alignment = Center ' To center it

    TextObj2.BackColor = RGB(128, 0, 64)

    TextObj2.ForeColor = RGB(255, 255, 255)

    TextObj2.Text = "CAD Display"

    MsgBox "Now adding a CADObject into the template. Click OK here, then switch to PC-DMIS, and use the Label Layout Wizard to specify your label configuration, then click OK on that dialog box."

    Sec2.ReportControls.Add ID_HOB_PCD_CAD_REPORT_OBJECT, 0, 110, 800, 1000

    

    ' Save the changes to the Report Template

    RepTemplate.SaveAs ("d:\temp\TestReportTemplate.rtp")

    MsgBox "The Report Template is now created. You can open it up inside of PC-DMIS to see what it looks like.", vbInformation, "Report Template Finished"

    RepTemplate.Close

    

End Sub

See Also

Copyright © 2019. Hexagon Manufacturing Intelligence – Metrology Software, Inc. All Rights Reserved.