none
Insert Columns Using a Macro MS Project 2016

    Frage

  • I am currently trying to move a lot of data from excel to project. I've been teaching myself VBA on the fly to get this task done but I am by no means an expert. I for the most part have the data exportation and importation handled, now I'm running in to problems trying to format the data. I have the tasks set to put the data in the correct fields and I've even renamed the fields so that when they're manually added after running the macro they have the correct name. For example if i run my macro from a blank project, it reaches out to the excel file, collects all the data, creates all the tasks and their subtasks, outline indents the subtasks correctly, and assigns the data within those tasks to the fields I want. So I say t.Text1 = objXL.Cells(i + 4, 12) (where t is a task variable and objXL is an excel application). The data is stored in the correct place and after running my code I am able to manually click add column, add Text1 for example, and it'll rename Text1 to my desired column header and the data will be with the correct subtask. My problem is trying to automate this process. I've tried writing a second macro to run after importing the data and using the macro recorder but to no avail. I record the macro, add my desired columns (Text1 - Text6 (i'm only using custom Text fields for now)), and stop recording but when i attempt to use that macro it throws an error. The way the macro recorder works it seems to try to reference the "Text1" before it creates it and it gets confused. I will be very grateful for any help in this task.

    Very Respectfully,

    Charles

    Dienstag, 12. Juni 2018 13:45

Antworten

  • Have you tried creating a custom table and view with the columns and headers you want, then applying that view after the data has churned?

    Coding it would be quite simple, e.g. ViewApply Name:="AViewILike"

    • Als Antwort markiert chas4739 Dienstag, 12. Juni 2018 14:59
    Dienstag, 12. Juni 2018 14:32

Alle Antworten

  • Have you tried creating a custom table and view with the columns and headers you want, then applying that view after the data has churned?

    Coding it would be quite simple, e.g. ViewApply Name:="AViewILike"

    • Als Antwort markiert chas4739 Dienstag, 12. Juni 2018 14:59
    Dienstag, 12. Juni 2018 14:32
  • Worked flawlessly, didn't even need to create a new macro or add any code to my existing macro. Just added the fields I needed, saved the view. Loaded the data, applied the view, boom done. Thank you so much
    Dienstag, 12. Juni 2018 14:59
  • You're welcome and thanks for ticking.

    Dienstag, 12. Juni 2018 18:15