private void RunMacro() { Console.WriteLine("uploading..."); Access.Application oAccess = new Access.Application(); oAccess.Visible = false; oAccess.OpenCurrentDatabase(fileName, false); try { oAccess.Run("ImportMacro"); oAccess.Quit(); } catch (Exception x) { oAccess.Quit(); System.Runtime.InteropServices.Marshal.ReleaseComObject(oAccess); oAccess = null; if (attemptNum < 3) { attemptNum++; Console.WriteLine("attempting time " + attemptNum); RunMacro(); } Console.WriteLine("something went wrong with the access macro: \n" + x.Message); } finally { System.Runtime.InteropServices.Marshal.ReleaseComObject(oAccess); oAccess = null; } }