VBA & Macro Problems

How to Select a Specific Task on a Timeline Bar using Microsoft Project VBA

Steven ParkerSteven Parker Nov 2, 2026 869 views

Question details

The user needs to select and target a specific task when multiple tasks share a single timeline bar using Microsoft Project VBA.

How to Select a Specific Task on a Timeline Bar Using VBA in Microsoft Project
Product
Microsoft Project
Device & OS
not provided
Scenario
Automating timeline formatting or adding callouts to specific tasks on a shared timeline bar via VBA scripts.
Observed behavior
Methods such as TaskOnTimelineEx and TimelineTextOnBar typically only affect the first task on a shared bar, making it unreliable or impossible to programmatically target subsequent individual tasks on that same bar.
Before you start

Before attempting to modify your timeline via VBA, verify whether your project requirements actually mandate grouping multiple tasks onto a single shared timeline bar, as separating them may bypass this limitation altogether.

Solution 1Recommended

Use Manual Selection and Separate Timeline Bars

Since the Microsoft Project VBA object model has limited support for shared timeline bars, manually adjusting or separating the bars is the most reliable approach.

The Microsoft Project object model struggles to differentiate between multiple tasks that occupy the exact same timeline bar. When utilizing commands designed to manipulate timeline text or callouts, the VBA macro engine generally defaults to the first object it parses on that bar.

1
Manually select the task

Open the Timeline view in Microsoft Project. Click directly on the specific task you want to modify within the shared timeline bar, and apply your formatting or callout manually using the ribbon tools.

2
Use separate timeline bars

Whenever practical, assign tasks to separate timeline bars rather than combining them into one. This allows VBA methods like TaskOnTimelineEx to reliably target the individual task since it is the only item residing on that specific bar.

3
Format outside the timeline object model

Apply custom text fields or flag fields to your tasks in the Gantt Chart view to drive visual differences or filtering, rather than relying solely on programmatic timeline bar manipulation.

Use Manual Selection and Separate Timeline Bars
VBA Limitation: Project VBA cannot reliably apply a callout or text change to an individual task other than the first task on a shared timeline bar. There is currently no native method to override this behavior.
Free Microsoft Office alternative

Choose WPS Office for a Lightweight and Compatible Experience

While Microsoft Project is used for complex scheduling, WPS Office provides an exceptional, free alternative for your broader documentation, data analysis, and VBA macro requirements. WPS Office offers robust spreadsheet capabilities with excellent macro support, making it easier to manage project data formats seamlessly.

  1. 1. Download WPS Office: Visit the official WPS Office website and download the free installation package.
  2. 2. Install the application: Run the installer and follow the on-screen prompts to set up the suite on your device in minutes.
  3. 3. Manage your project data: Open WPS Spreadsheets to utilize highly compatible VBA features for organizing and automating your project data tracking.
High compatibility with standard Microsoft Office formats including Word, Excel, and PowerPoint files.Robust support for VBA and macros in WPS Spreadsheets for advanced data automation and project tracking.Completely free, lightweight, and fast installation compared to traditional heavy Office suites.Familiar user interface ensuring zero learning curve for project managers and data analysts.
microsoft office alternative - wps office

Frequently Asked Questions

Why does the TimelineTextOnBar method only affect the first task on my timeline?

The Microsoft Project VBA object model currently has limited support for evaluating shared timeline bars. When multiple tasks are grouped on a single bar, the VBA methods default to interacting exclusively with the first task and cannot reliably target subsequent ones.

Can I use VBA macros to automatically split a shared timeline bar?

You can write a macro to update task properties so they no longer logically share a timeline bar in your data. However, properly rendering them as separate bars on the visual timeline often requires resetting the timeline view or manual formatting adjustments.

Is there a direct equivalent to Microsoft Project in WPS Office?

WPS Office does not include a dedicated project scheduling application identical to MS Project. However, project managers frequently utilize WPS Spreadsheets to create highly customizable Gantt charts, manage task lists, and execute VBA macros due to its extensive formatting and formula support.