Home > Enterprise >  Excel to Ms Project VBA - Insert task, set font, underline and Italics
Excel to Ms Project VBA - Insert task, set font, underline and Italics

Time:04-08

I have the following lines of code in VBA (Excel), successfully generating tasks in MS Project, with the correct outline level established. However, I would like to set the formatting of the 'Name field' of a specific task to be have an underline AND OR be italicized:

Sample Code:

ActiveProject.Tasks.Add ("Enter Task Name #1")
ActiveProject.Tasks ("Enter Task Name #1").OutlineLevel = 1
ActiveProject.Tasks.Add ("Enter Task Name #2")
ActiveProject.Tasks ("Enter Task Name #2").OutlineLevel = 2
ActiveProject.Tasks.Add ("Enter Task Name #3")
ActiveProject.Tasks ("Enter Task Name #3").OutlineLevel = 3

How would I go about setting formatting options to a task that is being imported or selecting the imported task and setting the required formatting?

CodePudding user response:

Once the tasks are entered, use the Find method to select the task and the apply formatting such as FontBold. For example:

Application.Find "Name", "equals", "Enter Task Name #2"
Application.FontBold
Application.FontItalic

Alternatively, use FontEx which can be used to apply multiple formats at once.

  • Related