I have an OpenProject function in Excel VBA that returns an Object. The purpose is to open a Microsoft Project file and return the Project as an object. The code is being written to be able to run in either Excel or Project. The OpenProject function opens the project correctly and correctly assigns it to the return value for the function. When I debug after the project is opened, I am able to use commands in the Immediate window to get the name of the project and number of tasks, so I know the object is valid.
However, when the Exit Function statement is executed I get an "Object required" error. I have seen this error occur on various statements but never on an Exit Function statement when the return object is valid. What could possibly cause this on Exit Function?
I have attached a file that has been skinnied down to the minimal code to reproduce the error.
Bookmarks