/// <summary> /// returns the valid file extension for the instance. for example ".doc" or ".docx" /// </summary> /// <param name="application">the instance</param> /// <returns>the extension</returns> private static string GetDefaultExtension(Word.Application application) { double version = Convert.ToDouble(application.Version, CultureInfo.InvariantCulture); if (version >= 12.00) return ".docx"; else return ".doc"; }
/// <summary> /// returns normal.dot template (normal.dotm in modern word versions) /// </summary> private Word.Template GetNormalDotTemplate(Word.Application application) { foreach (Word.Template installedTemplate in application.Templates) { if (installedTemplate.Name.StartsWith("normal", StringComparison.InvariantCultureIgnoreCase)) { return installedTemplate; } installedTemplate.Dispose(); } throw new IndexOutOfRangeException("Template not found."); }
private static string GetTemplateExtension(_Word.Application application) { double version = Convert.ToDouble(application.Version, CultureInfo.InvariantCulture); //System.Windows.Forms.MessageBox.Show(Convert.ToString(version)); //if (version >= 12.00) if (version > 11.0) { return ".dotx"; } else return ".dot"; }
string GetFileExtension(Word.Application application) { double wordVersion = Convert.ToDouble(application.Version, CultureInfo.InvariantCulture); if (wordVersion >= 12.0) return ".docm"; else return ".docm"; }