Object Model Reference : Classes : L : Layer : Methods : Layer.CreateCustomShape |
Function CreateCustomShape(TypeID As String, Parameter() As Variant) As Shape
Member of Layer
The CreateCustomShape method creates a custom shape on a layer.
Parameter
|
Description
|
TypeID
|
Specifies the Type ID of the desired custom shape
|
Parameter
|
Specifies the parameters for the desired custom shape
|
• |
For information on returning the properties of custom shapes, see the
Shape.Custom property.
|
CorelDRAW supports the automation of tables through the use of custom shapes. Here is the syntax for creating a table:
Function CreateCustomShape("Table", Left As Double, Top As Double, Right As Double, Bottom As Double, Columns As Long, Rows As Long) As Shape
For information on working with tables, see the TableShape class. The Shape.Custom property provides access to the properties and methods of the TableShape class.
The following VBA example creates a document containing a calendar for the month of January 2009, highlighting the cell for January 1st.
Sub Test() |
Dim s1 As Shape |
CreateDocument |
'Create a Table with 7 columns and 7 rows |
Set s1 = ActiveLayer.CreateCustomShape("Table", 1, 10, 5, 7, 7, 6) |
'Add Days of the Week to the each column in Row 1 |
s1.Custom.Cell(1, 1).TextShape.Text.Story = "Sun" |
s1.Custom.Cell(2, 1).TextShape.Text.Story = "Mon" |
s1.Custom.Cell(3, 1).TextShape.Text.Story = "Tue" |
s1.Custom.Cell(4, 1).TextShape.Text.Story = "Wed" |
s1.Custom.Cell(5, 1).TextShape.Text.Story = "Thu" |
s1.Custom.Cell(6, 1).TextShape.Text.Story = "Fri" |
s1.Custom.Cell(7, 1).TextShape.Text.Story = "Sat" |
'Add a row above the first column |
s1.Custom.AddRow 1 |
'Merge the cells in row |
'Add the Title 'January' |
'Center the text |
s1.Custom.Rows(1).Cells.All.Merge |
s1.Custom.Cell(1, 1).TextShape.Text.Story = "January" |
s1.Custom.Cell(1, 1).TextShape.Text.Story.Words.All.Size = 22 |
s1.Custom.Cell(1, 1).TextShape.Text.Story.Alignment = _ |
cdrCenterAlignment |
'Populate the calendar with dates |
Dim i As Integer |
For i = 1 To 31 |
'Insert the numbers starting at cell 13 (ie 1+12) |
s1.Custom.Cells(i + 12).TextShape.Text.Story = i |
Next i |
'Merge the cells with no date |
s1.Custom.Cells.Range(9, 10, 11, 12).Merge |
'Place a fill in the cells containing no dates |
Dim f1 As Fill |
Set f1 = ActiveDocument.CreateFill("EmptyCellFill") |
f1.ApplyUniformFill CreateRGBColor(220, 220, 220) |
s1.Custom.Cells.Range(9, 10, 11, 12).ApplyFill f1 |
'Put a border around the tableshape |
s1.Outline.Width = 0.05 |
'Put a border around row 1 of the tableshape |
s1.Custom.Rows(1).Cells.All.Borders.All.Width = 0.05 |
'Put a green border around the January 1st cell |
s1.Custom.Cells(10).Borders.All.Width = 0.05 |
s1.Custom.Cells.Range(10).Borders.All.Color.RGBAssign 0, 255, 0 |
End Sub |
Copyright 2013 Corel Corporation. All rights reserved.