Project::Pages

Contents

Description

Collection of all the pages in the project.

 

Access a collection of pages by index.

 

Get a PageBase object by name.

Syntax

Collection<PageBase> Pages

PageBase Pages(int index = -1)

PageBase Pages(LPCSTR lpcszName)

Parameters

index
[input] The 0-offset index of the PageBase object in the open project, or default -1 for the active page.

lpcszName
[input] Short Name of the page in Origin.

Return

Returns a valid PageBase object for the index'th PageBase or the active PageBase or an invalid PageBase object.

Returns a valid PageBase object having the short name lpcszName or an invalid PageBase object.

Examples

EX1

// This example assumes several existing windows of different types
// such as worksheets, graphs, matrices, layouts, etc.
int Project_Pages_ex1()
{
    // Loop over all the pages in the project and display their names
    foreach(PageBase pg in Project.Pages)
    {
        out_str(pg.GetName());
    }
    return 0;
}

EX2

// This example assumes several existing windows in Origin
int Project_Pages_ex2()
{
        PageBase pb = Project.Pages(0); // Get the first page
        if( pb.IsValid() )
                out_str(pb.GetName()); // Display the name of the first created page
        pb = Project.Pages(); // Get the active page
        if( pb.IsValid() )
                out_str(pb.GetName()); // Display the name of the active page
        return 0;
}

EX3

void Project_Pages_ex3(string strName = "Book1")
{
        PageBase pb = Project.Pages(strName); // Get the PageBase for the window in Origin having the short name strName
        if( !pb.IsValid() )
        {
                printf("%s is not a valid window\n", strName);
                return;
        }
        // try to cast into a workbook
        WorksheetPage wp = pb;
        if(!wp)
        {
                printf("%s is not a workbook\n", strName);
                return;
        }
        Worksheet wks = wp.Layers(); // get active sheet
        printf("%s's top sheet has %d columns and %d rows\n", wp.GetName(), wks.GetNumCols(), wks.GetNumRows()); 
}

Remark

header to Include

origin.h

See Also

Project::WorksheetPages, Project::Notes, Project::MatrixPages, Project::GraphPages, Project::LayoutPages, Project::LooseDatasetNames, Project::DatasetNames

Reference