Results 1 to 7 of 7

Thread: Solved: how to read data from a closed MS Project file into MS Word

  1. #1
    VBAX Regular
    Joined
    Sep 2012
    Posts
    33
    Location

    Solved: how to read data from a closed MS Project file into MS Word

    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/pro...-645/#post2830

    and this other one, i just cant seem to figure out

    http://www.mrexcel.com/forum/excel-q...ml#post3322679

    pls i need help

  2. #2
    VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,273
    Location
    Cross-posted at: http://windowssecrets.com/forums/sho...a-into-Ms-Word
    For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3

  4. #4
    VBAX Regular
    Joined
    Sep 2012
    Posts
    33
    Location
    Wow, its been a while i've been here, will post my code to this problem as soon as i get settled down again.

  5. #5
    VBAX Regular
    Joined
    Sep 2012
    Posts
    33
    Location
    Okay guys, here is my code to do the import.

    [vba]
    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[/vba]


    well i think that's it for now.

    Thanks.

  6. #6
    VBAX Newbie
    Joined
    Jun 2013
    Posts
    1
    Location
    No problem, I didn't realize how popular this feature was.

  7. #7
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,710
    Location
    Huh

Posting Permissions

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