问题
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:
- Create a reference to the Project application (
CreateObject
) - 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