AlignData Property Example for Microsoft Project 2002This 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.
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
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.
You can copy and paste the Microsoft VBA code below.
To create a new macro
- On the Tools menu, point to Macro and click Macros.
- Type a name for your new macro in the Macro name box.
- Select the project where you wish to create the macro in the Macros in box.
- Click Create.
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