Skip to content

Instantly share code, notes, and snippets.

@vmussak
Created July 7, 2019 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vmussak/46ffdb88f36a02f0438b87a8574368f1 to your computer and use it in GitHub Desktop.
Save vmussak/46ffdb88f36a02f0438b87a8574368f1 to your computer and use it in GitHub Desktop.
string caminho = @"C:\Users\Vinicius Mussak\Desktop\ReplaceDocxExample\ReplaceDocxExample\";
static void Replace()
{
using(var documento = DocX.Load(caminho + "documento.docx"))
{
documento.ReplaceText("#nome", "Vinicius Mussak");
string mes = DateTime.Now.ToString("MMMM", CultureInfo.CreateSpecificCulture("pt-br"));
documento.ReplaceText("#mes", mes);
documento.SaveAs(caminho + "novo-documento.docx");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment