Skip to content

Instantly share code, notes, and snippets.

@felixlindemann
Last active December 20, 2015 22:29
Show Gist options
  • Save felixlindemann/6205396 to your computer and use it in GitHub Desktop.
Save felixlindemann/6205396 to your computer and use it in GitHub Desktop.
c# vsto savefileas
public void Save()
{
Saving = true;
try
{
writeProperties();
Document doc = getDoc();
FileInfo f = new FileInfo(doc.FullName);
String strFileName = String.Format(@"{0}\{1} - v.{2}.{3}.{4}.docx", f.Directory.FullName, DocTitle, Revision, Version, Build);
object missing = System.Reflection.Missing.Value;
object fileName = strFileName;
object format = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatDocumentDefault;
doc.SaveAs(ref fileName, ref format, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
throw;
}
Saving = false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment