MyXl is declared in cmdOpen_Click and should be passed to Variables, otherwise it will be undefined.
public void Variables(Excel.Application MyXl)
Also, about the next line:
object ws;
Use specific type declaration for other excel classes like workbooks and worksheets:
Excel.Workbook wb;
Excel.Worksheet ws;
Good luck!