public Form1() { InitializeComponent(); //initialize remoting RemotingConfiguration.Configure("WordRemoteConverter.exe.config", false); RemotingConfiguration.RegisterWellKnownServiceType(new RemoteConverter().GetType(), "RemoteConverter", WellKnownObjectMode.Singleton); //check if word 2013 is available try { using (SingleWordApp wordapp = new SingleWordApp()) { if (wordapp.WordIsAvailable) { lbl_wordinstalled.ForeColor = Color.Green; lbl_wordinstalled.Text = "available"; } else { lbl_wordinstalled.ForeColor = Color.Red; lbl_wordinstalled.Text = "not available"; } } } catch { lbl_wordinstalled.ForeColor = Color.Red; lbl_wordinstalled.Text = "not available"; } }
public bool WordIsAvailable() { if (!checkedword) { try { if (wordApp == null) { using (SingleWordApp tempWordApp = new SingleWordApp()) { wordavailable = tempWordApp.WordIsAvailable; } } else { wordavailable = wordApp.WordIsAvailable; } } catch { wordavailable = false; } checkedword = true; } return(wordavailable); }
public void Dispose() { if (wordApp != null && !wordApp.IsBusy) { wordApp.Dispose(); wordApp = null; } }
public string Convert(string source, out Exception ex) { if (wordApp == null) { wordApp = new SingleWordApp(30); } if (wordApp != null && !wordApp.IsBusy) { return(wordApp.ConvertToPdf(source, 15, out ex)); } ex = new Exception("WordApp is null or Word is busy"); return(null); }