View Full Version : Solved: how to read data from a closed MS Project file into MS Word
hometech
11-22-2012, 01:37 AM
Please any ideas on how to import Data MS Project into MS Word, i have tried some approaches that did not seem to work and now i'm in a little bit of a crunch for time. i provided links to the various attempts made.
this one gives me a prvider cannot be found error
http://www.excelfox.com/forum/f5/provider-cannot-found-may-not-properly-installed-645/#post2830
and this other one, i just cant seem to figure out
http://www.mrexcel.com/forum/excel-questions/670636-reading-data-ms-project-closed-file-into-ms-word.html#post3322679
pls i need help
macropod
11-22-2012, 06:08 PM
Cross-posted at: http://windowssecrets.com/forums/showthread.php/150596-Getting-Data-into-Ms-Word
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
hometech
11-23-2012, 01:51 AM
Omission error on my part
http://windowssecrets.com/forums/showthread.php/150596-Getting-Data-into-Ms-Word
hometech
12-07-2012, 03:28 AM
Wow, its been a while i've been here, will post my code to this problem as soon as i get settled down again.
hometech
12-12-2012, 07:52 AM
Okay guys, here is my code to do the import.
Sub importTasks()
Dim appProj As MSProject.Application
Dim aProg As MSProject.Project
Dim tsk As MSProject.Task
Dim myString As String
Dim myStartDate As Date
Dim myEndDate As Date
Dim myDuration As Date
Dim noRows As Integer
Set appProj = CreateObject("Msproject.Application")
appProj.FileOpenEx Name:="C:\timetrack.mpp", ReadOnly:=True, openpool:=pjPoolReadOnly
' Do not show alerts
appProj.DisplayAlerts = False
'set the active project
Set aProg = appProj.ActiveProject
'the file should be opened in background
appProj.Visible = False
'
myStartDate = Format(ActiveProject.ProjectStart, "mm/dd/yyyy")
myEndDate = Format(ActiveProject.ProjectFinish, "mm/dd/yyyy")
'you could create a table to receive the values from project file
ActiveDocument.Tables(1).Cell(1, 1).Range = myStartDate
ActiveDocument.Tables(1).Cell(1, 2).Range = myEndDate
' to select all the task and write it to table
With ActiveDocument.Tables(1).Cell(2, 1).Range
.delete
For Each tsk In ActiveProject.Tasks
myString = tsk.Name & vbTab & "" & tsk.Start& vbTab & "" tsk.Finish & vbCrLf
next tsk
'convert task items to table
.ConvertToTable vbTab, numrows:=noRows, numcolumns:=6, InitialColumnWidth:=150, _
Format:=wdTableFormatGrid1, applyborders:=True, AutoFitBehavior:=wdAutoFitFixed
End With
'Then add any other thing you like
'exit and close file, don't prompt to save
appProj.FileCloseAllEx pjDoNotSave, CheckIn:=True
End Sub
well i think that's it for now.
Thanks.
Regent45
06-15-2013, 12:25 AM
No problem, I didn't realize how popular this feature was.
fumei
06-16-2013, 11:41 PM
Huh
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.