Automate creating n Microsoft Project files from an excel file with n rows

痴心易碎 提交于 2020-07-09 11:50:36

问题


How would I go about creating n Microsoft Project files from an Excel file with n rows using some form of automation? There are about 2000 rows in my excel file and i would like to create 2000 Microsoft Project files that utilize the same mapping as one another. I would like to automate this rather than do each manually.


回答1:


You can do this in an automated way either from Project or Excel using the FileOpenEx method of the Project application object to create a schedule file and load it with tasks from an Excel or csv file. This method has a parameter where you can specify the name of a map stored in your global file.

Presuming you are automating Project from Excel, the basic steps are:

  1. Create a reference to the Project application (CreateObject)
  2. Loop through your list of projects (rows in your Excel file)
    • Use the FileOpenEx method to create a Project file for each one
    • Close the Project file

The source data for each of the schedule files needs to be in its own file (Excel or csv) as the FileOpenEx method will import all rows into the new schedule file.

If your source data is all in one Excel file and the number of tasks for each schedule is small, you can automate adding the tasks one-by-one (use Projects.Add for a new project, then Tasks.Add).



来源:https://stackoverflow.com/questions/40389578/automate-creating-n-microsoft-project-files-from-an-excel-file-with-n-rows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!