Measurement and Automation will scan the GPIB bus for any instruments it can find, and you do not have to supply the GPIB address to it.
Whereas in your program, you most probably had to specify a GPIB address when opening the session.
From the error code, it appears that when you opened the session to the instrument it failed. Do you trap the error when opening the session.
Later when you try to use the session handle to talk to the instrument, it was an invalid handle, and therefore not able to talk to the instrument.
Check you open session code, and see if you catch any return value. If you do, and it opens the session properly, let me know, and I can give you more advice.
Regards
Chris