private void ReemplazarDatosIdioma(Word.Range rng_idi, DataRowView oFila) { //Ejemplo de Buscar y reemplazar el nombre dentro del rango. Word.Find fnd = rng_idi.Find; //Clear existing formatting; fnd.ClearFormatting(); fnd.Replacement.ClearFormatting(); fnd.Text = "{idioma}"; fnd.Replacement.Text = oFila["T020_DESCRIPCION"].ToString(); ExecuteReplace(fnd); fnd.Text = "{nivel_lectura}"; fnd.Replacement.Text = oFila["T013_LECTURA"].ToString(); ExecuteReplace(fnd); fnd.Text = "{nivel_escritura}"; fnd.Replacement.Text = oFila["T013_ESCRITURA"].ToString(); ExecuteReplace(fnd); fnd.Text = "{nivel_conversacion}"; fnd.Replacement.Text = oFila["T013_ORAL"].ToString(); ExecuteReplace(fnd); fnd.Text = "{titulo_idioma}"; fnd.Replacement.Text = oFila["T021_TITULO"].ToString(); ExecuteReplace(fnd); }
private Boolean ExecuteReplace(Word.Find find, Object replaceOption) { // Simple wrapper around Find.Execute: Object findText = Type.Missing; Object matchCase = Type.Missing; Object matchWholeWord = Type.Missing; Object matchWildcards = Type.Missing; Object matchSoundsLike = Type.Missing; Object matchAllWordForms = Type.Missing; Object forward = Type.Missing; Object wrap = Type.Missing; Object format = Type.Missing; Object replaceWith = Type.Missing; Object replace = replaceOption; Object matchKashida = Type.Missing; Object matchDiacritics = Type.Missing; Object matchAlefHamza = Type.Missing; Object matchControl = Type.Missing; return(find.Execute(findText, matchCase, matchWholeWord, matchWildcards, matchSoundsLike, matchAllWordForms, forward, wrap, format, replaceWith, replace, matchKashida, matchDiacritics, matchAlefHamza, matchControl)); }
private void ReemplazarDatosExperiencias(Word.Range rng_exp, DataRowView oFila) { //Ejemplo de Buscar y reemplazar el nombre dentro del rango. Word.Find fnd = rng_exp.Find; //Clear existing formatting; fnd.ClearFormatting(); fnd.Replacement.ClearFormatting(); fnd.Text = "{fecha_exp}"; fnd.Replacement.Text = oFila["T812_FINICIO"].ToString() + " - " + oFila["T812_FFIN"].ToString(); ExecuteReplace(fnd); fnd.Text = "{funcion_exp}"; fnd.Replacement.Text = oFila["T035_DESCRIPCION"].ToString(); ExecuteReplace(fnd); fnd.Text = "{cliente_exp}"; fnd.Replacement.Text = oFila["CLIENTE"].ToString(); ExecuteReplace(fnd); fnd.Text = "{tareas_exp}"; fnd.Replacement.Text = oFila["T813_FUNCION"].ToString(); ExecuteReplace(fnd); fnd.Text = "{tecnologias_exp}"; fnd.Replacement.Text = oFila["ENTORNO"].ToString(); ExecuteReplace(fnd); }
private void ReemplazarDatos(Word.Range rng_datos, string[] aDatos) { //Ejemplo de Buscar y reemplazar el nombre dentro del rango. Word.Find fnd = rng_datos.Find; //Clear existing formatting; fnd.ClearFormatting(); fnd.Replacement.ClearFormatting(); fnd.Text = "{nombre}"; fnd.Replacement.Text = aDatos[0];// "Nombre Profesional"; ExecuteReplace(fnd); fnd.Text = "{nif}"; fnd.Replacement.Text = aDatos[1];// "123456789Z"; ExecuteReplace(fnd); fnd.Text = "{perfil}"; fnd.Replacement.Text = aDatos[2];// "GERENTE"; ExecuteReplace(fnd); fnd.Text = "{fnacim}"; fnd.Replacement.Text = aDatos[3];// "15/02/1973"; ExecuteReplace(fnd); fnd.Text = "{foto}"; fnd.Replacement.Text = "";// "15/02/1973"; ExecuteFind(fnd); rng_datos.Select(); rng_datos.SetRange(rng_datos.Start, rng_datos.End); Word.Selection currentSelection = wordApplication.Selection; currentSelection.MoveRight(); currentSelection.InlineShapes.AddPicture("D:\\Proyectos\\PRUEBAS\\WordTest01\\images\\01.jpg"); ExecuteReplace(fnd); //TableRow theRow = theTable.Elements<TableRow>().Last(); //Word.Row oLastRow = newDocument.Bookmarks["Tabla01"].Range.Tables[1].Rows.Last; // Word.Row oLastRow = rng_datos.Tables[1].Rows.Last; rng_datos.Tables[1].Rows.Add(); rng_datos.Tables[1].Rows.Last.Cells[1].Select(); wordApplication.Selection.TypeText("Texto en la primera celda"); rng_datos.Tables[1].Rows.Last.Cells[2].Select(); wordApplication.Selection.TypeText("Texto en la segunda celda"); rng_datos.Tables[1].Rows.Last.Cells[3].Select(); wordApplication.Selection.TypeText("Texto en la tercera celda"); //oLastRow //TableRow rowCopy = (TableRow)theRow.CloneNode(true); //rowCopy.Descendants<TableCell>().ElementAt(0).Append(new Paragraph(new Run(new Text(order.Contact.ToString())))); //rowCopy.Descendants<TableCell>().ElementAt(1).Append(new Paragraph(new Run(new Text(order.NameOfProduct.ToString())))); //rowCopy.Descendants<TableCell>().ElementAt(2).Append(new Paragraph(new Run(new Text(order.Amount.ToString())))); //theTable.AppendChild(rowCopy); //Word.Range rowrng = oLastRow.Range; //rowrng.Copy(); }
private void CargarDatosPersonales(Word.Range rng_datos, DataRow oFila) { //Ejemplo de Buscar y reemplazar el nombre dentro del rango. Word.Find fnd = rng_datos.Find; //Clear existing formatting; fnd.ClearFormatting(); fnd.Replacement.ClearFormatting(); fnd.Text = "{nombre}"; fnd.Replacement.Text = oFila["Profesional"].ToString(); ExecuteReplace(fnd); fnd.Text = "{nif}"; fnd.Replacement.Text = oFila["t001_cip"].ToString(); ExecuteReplace(fnd); fnd.Text = "{perfil}"; fnd.Replacement.Text = oFila["t035_descripcion"].ToString(); ExecuteReplace(fnd); fnd.Text = "{fnacimiento}"; fnd.Replacement.Text = ((DateTime)oFila["t001_fecnacim"]).ToShortDateString(); ExecuteReplace(fnd); fnd.Text = "{foto}"; fnd.Replacement.Text = "";// "15/02/1973"; ExecuteFind(fnd); rng_datos.Select(); rng_datos.SetRange(rng_datos.Start, rng_datos.End); bool bHayFoto = false; if (oFila["t001_foto"] != DBNull.Value) { bHayFoto = true; //sPathDocs SUPER.Capa_Negocio.Utilidades.ByteArrayToFile(sPathDocs + "..\\temp\\foto.jpg", (byte[])oFila["t001_foto"]); } if (bHayFoto) { Word.Selection currentSelection = wordApplication.Selection; currentSelection.MoveRight(); //currentSelection.InlineShapes.AddPicture("D:\\Proyectos\\PRUEBAS\\WordTest01\\images\\01.jpg"); currentSelection.InlineShapes.AddPicture(sPathDocs + "..\\temp\\foto.jpg"); System.IO.File.Delete(sPathDocs + "..\\temp\\foto.jpg"); } ExecuteReplace(fnd); }
private void CargarDatosPersonales(Word.Range rng_datos, string[] aDatos) { //Ejemplo de Buscar y reemplazar el nombre dentro del rango. Word.Find fnd = rng_datos.Find; //Clear existing formatting; fnd.ClearFormatting(); fnd.Replacement.ClearFormatting(); fnd.Text = "{nombre}"; fnd.Replacement.Text = aDatos[0];// "Nombre Profesional"; ExecuteReplace(fnd); fnd.Text = "{nif}"; fnd.Replacement.Text = aDatos[1];// "123456789Z"; ExecuteReplace(fnd); fnd.Text = "{perfil}"; fnd.Replacement.Text = aDatos[2];// "GERENTE"; ExecuteReplace(fnd); fnd.Text = "{fnacimiento}"; fnd.Replacement.Text = aDatos[3];// "15/02/1973"; ExecuteReplace(fnd); fnd.Text = "{foto}"; fnd.Replacement.Text = "";// "15/02/1973"; ExecuteFind(fnd); rng_datos.Select(); rng_datos.SetRange(rng_datos.Start, rng_datos.End); Word.Selection currentSelection = wordApplication.Selection; currentSelection.MoveRight(); currentSelection.InlineShapes.AddPicture("D:\\Proyectos\\PRUEBAS\\WordTest01\\images\\01.jpg"); ExecuteReplace(fnd); }
public override void Inspect(Word.Document doc, out MsoDocInspectorStatus status, out string result, out string action) { InspectResult.Clear(); Cache.Clear(); Word.Range range = doc.Content; Word.Find find = range.Find; find.Forward = true; find.Text = "http*"; find.MatchWildcards = true; if (find.Execute()) { int start = range.Start; while (start > 0) { string text = String.Empty; Word.Range character = range.Characters[1]; while (null != character) { string characterText = character.Text; bool isEndLink = false; foreach (string item in _linkEnds) { if (characterText == item) { isEndLink = true; break; } } if (!isEndLink) { text += character.Text; character = character.Next(); } else { break; } } foreach (string item in _bitly) { if (text.StartsWith(item)) { InspectResult.Add(start, text); break; } } if (!find.Execute()) { break; } start = range.Start; } } if (InspectResult.Count > 0) { status = MsoDocInspectorStatus.msoDocInspectorStatusIssueFound; result = String.Format("{0} link(s) found.", InspectResult.Count); action = "Deobfuscate Links."; } else { status = MsoDocInspectorStatus.msoDocInspectorStatusDocOk; result = "No links found."; action = "No links to change."; } }
private Boolean ExecuteFind(Word.Find find) { return(ExecuteFind(find, Type.Missing, Type.Missing)); }
private Boolean ExecuteReplace(Word.Find find) { return(ExecuteReplace(find, WdReplace.wdReplaceAll)); }