The object with block or variable not set error gets thrown during the initializing of the API.
Please try the following until the issue is resolved:
1. Ensure the API has been unlocked
2. If the code is running on the Raiser's Edge Server, specify the .amServer parameter in the Init Statement. If this is on a standalone, please specify .amStandalone in the Init Statement.
3. Be sure that all objects in the code that are initialized are properly closed down and that the Com Objects are all properly release as well as setting the API.SignOutOnTerminate Value equal to True.