Share via


Document Object (Publisher)

Represents a publication.

Example

Use the ActiveDocument property to refer to the current publication. This example adds a table to the first page of the active publication.

Sub NewTable() 
 With ActiveDocument.Pages(1).Shapes 
 .AddTable NumRows:=3, NumColumns:=3, Left:=72, Top:=300, _ 
 Width:=488, Height:=36 
 With .Item(1).Table.Rows(1) 
 .Cells(1).TextRange.Text = "Column1" 
 .Cells(2).TextRange.Text = "Column2" 
 .Cells(3).TextRange.Text = "Column3" 
 End With 
 End With 
End Sub

You can also write the above routine by using a reference to the ThisDocument module. This example uses a ThisDocument reference instead of ActiveDocument.

Sub PrintPublication() 
 With ThisDocument.Pages(1).Shapes 
 .AddTable NumRows:=3, NumColumns:=3, Left:=72, Top:=300, _ 
 Width:=488, Height:=36 
 With .Item(1).Table.Rows(1) 
 .Cells(1).TextRange.Text = "Column1" 
 .Cells(2).TextRange.Text = "Column2" 
 .Cells(3).TextRange.Text = "Column3" 
 End With 
 End With 
End Sub