The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

AlignData Property Example for Microsoft Project 2002

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Randall Isenhour
Microsoft Corporation

August 2002


Running the code example
Use a macro to change the display of table data
AlignData property sample code


The following code sample changes the alignment of a column in an entry table. The macro asks for input from the user to indicate which column the user wants to center, then changes the display and refreshes the view. (2 pages)

Note   If the active view is not the Entry Table, the macro returns a trappable error (error code 1100). To avoid the run-time error, apply the Entry Table to the current view before setting the TableFields property in the code below.


  • Microsoft® Project Professional 2002 or Microsoft Project Standard 2002

Running the code example

This code example assumes that you are familiar with Microsoft Project and Microsoft Visual Basic® for Applications (VBA), and that you can write or reuse supplementary code as necessary.

To run this code example, you must have Microsoft Project 2002 (either Standard or Professional edition) installed on your computer. You can either paste the code into the Microsoft Visual Basic Editor (VBE) in Microsoft Project or into your VBA project.

Use a macro to change the display of table data

You can copy and paste the Microsoft VBA code below.

To create a new macro

  1. On the Tools menu, point to Macro and click Macros.
  2. Type a name for your new macro in the Macro name box.
  3. Select the project where you wish to create the macro in the Macros in box.
  4. Click Create.

AlignData property sample code

Sub AutoWrap()
   fieldNumber = InputBox$(Prompt:="Enter the number of the " _
      & "column you want to center in the Entry table." _
      & Chr(13) & "For example, Column 1 is the Indicators " _
      & "column.")
   ActiveProject.TaskTables("Entry").TableFields(fieldNumber _
      + 1).AlignData = pjCenter
   TableApply Name:="&Entry"
End Sub