U
urgent!!
I've added the reference to Microsoft Project 11.0 Object Library which path
is C:\Program Files\Microsoft Office\OFFICE11\MSPRJ.OLB. After referenced
I've get Microsoft HTML Object Library, Microsoft Office 11.0 Object Library,
Microsoft Project 11.0 Object Library and Microsoft Visual Basic for
Applications Extensibility 5.3. Below are my codes:
Dim theFile As String
OpenFileDialog1.InitialDirectory = Application.ExecutablePath
OpenFileDialog1.DefaultExt = "mpp" 'custom format
OpenFileDialog1.FileName = ""
OpenFileDialog1.Filter = "Microsoft Project Files" _
& " (*.mpp)|*.mpp"
OpenFileDialog1.ShowDialog()
theFile = OpenFileDialog1.FileName
Dim pj As New MSProject.Application
pj.Visible = True
pj.FileOpen(theFile)
Debug.Print(pj.ActiveProject.Name)
Debug.Print(pj.ActiveProject.Tasks.Count)
Dim tsk As MSProject.Application
For Each tsk In pj.ActiveProject.Tasks
Debug.Print(pj.ActiveProject.Name)
Next
If i replace the line "Dim pj As MSProject.Application" with
"Microsoft.Office.Interop.MSProject.Application", it is highlighted with blue
line saying Microsoft.Office.Interop.MSProject.Application is not defined.
But if no changes, I get error during runtime. I've used OpenFileDialog to
get the Project file which is at dekstop.
is C:\Program Files\Microsoft Office\OFFICE11\MSPRJ.OLB. After referenced
I've get Microsoft HTML Object Library, Microsoft Office 11.0 Object Library,
Microsoft Project 11.0 Object Library and Microsoft Visual Basic for
Applications Extensibility 5.3. Below are my codes:
Dim theFile As String
OpenFileDialog1.InitialDirectory = Application.ExecutablePath
OpenFileDialog1.DefaultExt = "mpp" 'custom format
OpenFileDialog1.FileName = ""
OpenFileDialog1.Filter = "Microsoft Project Files" _
& " (*.mpp)|*.mpp"
OpenFileDialog1.ShowDialog()
theFile = OpenFileDialog1.FileName
Dim pj As New MSProject.Application
pj.Visible = True
pj.FileOpen(theFile)
Debug.Print(pj.ActiveProject.Name)
Debug.Print(pj.ActiveProject.Tasks.Count)
Dim tsk As MSProject.Application
For Each tsk In pj.ActiveProject.Tasks
Debug.Print(pj.ActiveProject.Name)
Next
If i replace the line "Dim pj As MSProject.Application" with
"Microsoft.Office.Interop.MSProject.Application", it is highlighted with blue
line saying Microsoft.Office.Interop.MSProject.Application is not defined.
But if no changes, I get error during runtime. I've used OpenFileDialog to
get the Project file which is at dekstop.