Consulting

Results 1 to 3 of 3

Thread: Ltrim macro working, yet throwing Error 91 (Object variable not set)

  1. #1

    Ltrim macro working, yet throwing Error 91 (Object variable not set)

    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.

  2. #2
    VBAX Tutor
    Joined
    Mar 2014
    Posts
    210
    Location
    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.



  3. #3
    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •