I have created a mail merged document at run time.
However, I cannot open the document everytime, sometime it did not get
opened, sometimes it can.
The document may be Word or text file.
public static void OpenDocument(st ring aFilename)
{
IntPtr result;
Process convertProcess = new Process();
try
{
convertProcess. StartInfo.Domai n = "";
convertProcess. StartInfo.FileN ame = aFilename;
convertProcess. StartInfo.Creat eNoWindow = true;
convertProcess. StartInfo.Windo wStyle =
System.Diagnost ics.ProcessWind owStyle.Maximiz ed;
convertProcess. StartInfo.Stand ardErrorEncodin g = null;
convertProcess. StartInfo.Stand ardOutputEncodi ng = null;
convertProcess. StartInfo.UseSh ellExecute = true;
convertProcess. StartInfo.LoadU serProfile = false;
convertProcess. StartInfo.Passw ord = null;
convertProcess. StartInfo.UserN ame = "";
convertProcess. Start();
convertProcess. Dispose();
}
catch (Exception e)
{
try
{
convertProcess. Dispose();
}
catch
{
}
}
}
However, I cannot open the document everytime, sometime it did not get
opened, sometimes it can.
The document may be Word or text file.
public static void OpenDocument(st ring aFilename)
{
IntPtr result;
Process convertProcess = new Process();
try
{
convertProcess. StartInfo.Domai n = "";
convertProcess. StartInfo.FileN ame = aFilename;
convertProcess. StartInfo.Creat eNoWindow = true;
convertProcess. StartInfo.Windo wStyle =
System.Diagnost ics.ProcessWind owStyle.Maximiz ed;
convertProcess. StartInfo.Stand ardErrorEncodin g = null;
convertProcess. StartInfo.Stand ardOutputEncodi ng = null;
convertProcess. StartInfo.UseSh ellExecute = true;
convertProcess. StartInfo.LoadU serProfile = false;
convertProcess. StartInfo.Passw ord = null;
convertProcess. StartInfo.UserN ame = "";
convertProcess. Start();
convertProcess. Dispose();
}
catch (Exception e)
{
try
{
convertProcess. Dispose();
}
catch
{
}
}
}
Comment