I had the same issue and your suggestion really helped.Please let me know if need to give anything in inputs/outputs?
I have declared it as:
dim SapGuiAuto As Object
"Internal : Exception: Object reference not set to an instance of an object."
Dim SapGuiAuto As Object Dim application As Object Dim connection As Object Dim session As Object Dim Grid As Object SapGuiAuto = GetObject("SAPGUI") application = SapGuiAuto.GetScriptingEngine connection = application.Children(0) session = connection.Children(0) session.findById("wnd").maximize Grid = session.findById("wnd/usr/subSUB0:SAPLMEGUI:0010/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211").selectAllColumns Columns = Grid.GetColumnPosition("PLNT") SAP_Plant = Grid.GetCellValue(0, "PLNT")