Launch excel file using Process object
I am getting error trying to launch the specified executable is not a valid application for this os platform , I am trying to launch a Template.XLS file save values in the files then close file. once i close file I the process detects that the file is close and then i go do something, can someone assist me.
using (StatusBusy busy = new StatusBusy("Launching template.xls. Please wait patiently..."))
{
if (File.Exists(fileName))
{
Process process = new Process();
process.EnableRaisingEvents = true;
process.Exited += new EventHandler(process_Exited);
process.StartInfo.UseShellExecute = false;
process.StartInfo.FileName = fileName;
process.WaitForExit();
if (process.ExitCode == 0)
{
MessageBox.Show("template.xlsprocess complete.");
return true;
}
else
{
MessageBox.Show(" template.xls process Failed.");
process.Kill();
return false;
}
}
else
{
MessageBox.Show("File does not exist");
return false;
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error occurred launching SN template. ",ex.Message);
return false;
}