The solution of aikudino is good indeed.
another work around is to use late binding.
maybe not the best practice, but then you don’t have to bother about references, e.g. :
dim OBJ_SapGuiAuto as Object = Microsoft.VisualBasic.GetObject(“SAPGUI”)
(And if ‘GetObject’ throws an error, try ‘CreateObject’ instead)