PDA

View Full Version : Using the findex return value



jroger05
03-29-2019, 12:08 PM
I am a novice in VBA and trying to tie some things from Project to Excel:

I am trying to look up a task in project, and then return fields from the task and then populate particular cells in Excel.

So I opened the project file successfully.
'Open MS Project file
PrjFullName = "C:\temp\wren.mpp" '<-- keep the MS-Project file name and path in a variable
PrjApp.Application.FileOpenEx PrjFullName
Set aProg = PrjApp.ActiveProject


' show all tasks
OutlineShowAllTasks
Set prjtasks = aProg.Tasks




' Set the type variable
type = "document"
' Go into the Project File and find the type in the task name
FindEx Field:="Text23", Test:="contains", Value:=type, Next:=True, MatchCase:=False, SearchAllFields:=False
SelectTaskField Row:=0, Column:="Name"
EditCopy

So...
The above code allows me to get one field, and then I can copy that item into Excel. However the above does not support error checking, ie if the findex doesn't find an entry then I need to know that. I was trying to use some sort of Boolean, but have been unsuccessful getting the return value from the FindEx. If the FindEx doesn't find anything the SelectTaskField defaults to the current row, which is not the desired behavior.

Thanks in advance.