Application.FilePageSetupLegend method (Project)
Creates a legend for printing views of task data.
Syntax
expression.FilePageSetupLegend (Name, TextWidth, LegendOn, Alignment, Text, LabelFontName, LabelFontSize, LabelFontBold, LabelFontItalic, LabelFontUnderline, LabelFontColor)
expression A variable that represents an Application object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
Name | Optional | String | The name of the view or report for which to set up legends for printing. |
TextWidth | Optional | Integer | The width of the text, in inches or centimeters. |
LegendOn | Optional | Long | The pages on which the legend appears. Can be one of the following PjLegend constants: pjNoLegend, pjAfterLastPage, or pjOnEveryPage. |
Alignment | Optional | Long | The alignment of the text in the legend. Can be one of the following PjAlignment constants: pjLeft, pjCenter, or pjRight. The default value is pjCenter. |
Text | Optional | String | The text to display in the legend. The special format codes can be included as part of the legend. |
LabelFontName | Optional | String | The name of the font. |
LabelFontSize | Optional | Integer | The size of the font in points. |
LabelFontBold | Optional | Boolean | True if the font is bold; otherwise, False. |
LabelFontItalic | Optional | Boolean | True if the font is italic; otherwise, False. |
LabelFontUnderline | Optional | Boolean | True if the font is underlined; otherwise, False. |
LabelFontColor | Optional | Long | The color of the font. Can be one the PjColor constants; see the PjColor constants table. |
Format codes
Format code | Description |
---|---|
&B | Turns bold printing on or off. |
&I | Turns italic printing on or off. |
&U | Turns underline printing on or off. |
&""fontname"" | Prints characters that follow the format code in the specified font. For example, &""Arial"". |
&nn | Prints characters that follow the format code in the specified font size. Use a two-digit number to specify a size in points. For example, &08. |
&P""path"" | Inserts the specified image. For example, &P"" [My Documents] \Image.gif"". The term [My Documents] represents the full path to your My Documents folder. |
&[Date] | Prints the current system date. |
&[Time] | Prints the current system time. |
&[File] | Prints the file name. |
&[Page] | Prints the page number. |
&[Pages] | Prints the total number of pages in the document. |
&[Project Title] | Prints the title. |
&[Company] | Prints the company name. |
&[Manager] | Prints the manager name. |
&[Start Date] | Prints the project start date. |
&[Finish Date] | Prints the project finish date. |
&[Current Date] | Prints the project current date. |
&[Status Date] | Prints the project status date. |
&[View] | Prints the view name. |
&[Report] | Prints the report name. |
&[Filter] | Prints the filter name. |
&[Saved Date] | Prints the last saved date. |
&[Subject] | Prints the subject. |
&[Author] | Prints the author. |
&[Keyword] | Prints the keyword(s). |
&[Field_Name] | Prints the value of the field specified with Field_Name. If a macro will be run in more than one language, the field specified with Field_Name must use the name localized for each language. For example, &[Actual Cost]. |
PjColor constants
constant | constant |
---|---|
pjColorAutomatic | pjNavy |
pjAqua | pjOlive |
pjBlack | pjPurple |
pjBlue | pjRed |
pjFuchsia | pjSilver |
pjGray | pjTeal |
pjGreen | pjYellow |
pjLime | pjWhite |
pjMaroon |
Return value
Boolean
Remarks
Using the FilePageSetupLegend method without specifying any arguments displays the Page Setup dialog box with the Legend tab selected.
FilePageSetupLegend works only with views of task data.
To edit a legend where the LabelFontColor can be a hexadecimal RGB value, use the FilePageSetupLegendEx method.
Example
The following example sets up a legend for printing.
Sub SetLegend()
Dim strLegend As String
strLegend = GetFontFormatCode("Arial")
strLegend = strLegend & "&BThis text will appear in the legend.&B"
Application.FilePageSetupLegend Text:=strLegend, _
Alignment:=pjCenter, LegendOn:=pjOnEveryPage
End Sub
Public Function GetFontFormatCode(strFontName As String) As String
GetFontFormatCode = "&" & Chr(34) & strFontName & Chr(34)
End Function
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.