PDA

View Full Version : Ltrim macro working, yet throwing Error 91 (Object variable not set)



adamhammock
09-23-2014, 09:19 AM
Here is the macro:


Sub lefttrim()



Dim All_Tasks As Tasks 'All the tasks in the Project

Dim Single_Task As Task 'A single task in the Project



Set All_Tasks = ActiveProject.Tasks



For Each Single_Task In All_Tasks

Single_Task.Name = Ltrim(Single_Task.Name) <(This line is throwing the error)

Next



End Sub


Does anyone have an idea as to why this would still perform the trim function, yet have an error? Thanks in advance.

ranman256
09-23-2014, 10:45 AM
The 91 comes from objects. So [Single_Task ] is not getting set.
Try
For Each Single_Task In ActiveProject.Tasks

Its possible Activeproject is NOT active.

adamhammock
09-23-2014, 11:02 AM
So replace

For Each Single_Task In All_Tasks
withFor Each Single_Task In ActiveProject.Tasks

I tried that just now and it's still giving me the 91 on the same line.