Article ID: 154787
Article Last Modified on 1/19/2007
Function ProjectOLE()
Dim ProjObj As MSProject.Application
Set ProjObj = CreateObject("msproject.application")
ProjObj.FileOpen "C:\Msoffice\Winproj\Library\Pert.mpp", _
ReadOnly:=True
ProjObj.Visible = True
' Run a macro.
ProjObj.Macro "ToggleReadOnly" ' Toggle file back to read-write.
' Add tasks to the project.
Dim i As Integer
Dim ProjDoc As MSProject.Project
Set ProjDoc = ProjObj.ActiveProject
For i = 1 To 10
ProjDoc.Tasks.Add Name:="Task" & i
Next i
' Change font properties.
ProjObj.SelectColumn
ProjObj.FontItalic True
' Go to a specific cell in the column.
ProjObj.EditGoTo 5, Date
' Print preview the file.
ProjObj.FilePrintPreview
'ProjObj.FilePrint ' Use this line to print the file.
'ProjObj.Filesave ' Use this line to save the file.
ProjObj.FileClose 0 ' 0=pjDoNotSave, 1=pjSave, 2=pjPromptSave.
ProjObj.Quit
Set ProjObj = Nothing
End Function
?ProjectOLE()
Keywords: kbhowto kbinterop kbprogramming KB154787