Foros del Web » Programando para Internet » ASPX (.net) »

Modificar word existente con Interop

Estas en el tema de Modificar word existente con Interop en el foro de ASPX (.net) en Foros del Web. Este es mi código para modificar el archivo de word con la dll de Interop.... Pero no funciona :( no marca ningún error simplemente el ...
  #1 (permalink)  
Antiguo 02/10/2015, 11:27
 
Fecha de Ingreso: enero-2013
Mensajes: 176
Antigüedad: 11 años, 3 meses
Puntos: 2
Modificar word existente con Interop

Este es mi código para modificar el archivo de word con la dll de Interop....
Pero no funciona :( no marca ningún error simplemente el documento no tiene los cambios que debería

Alguien me puede ayudar??? Gracias!

Código ASP:
Ver original
  1. private void cargaWord()
  2.  {
  3.  
  4.             object o = Missing.Value;
  5.             object oFalse = false;
  6.             object oTrue = true;
  7.  
  8.             Word._Application app = null;
  9.             Word.Documents docs = null;
  10.             Word.Document doc = null;
  11.  
  12.             object path = ruta+@"\Resources\Precios.doc";
  13.  
  14.             try
  15.             {
  16.                 app = new Word.Application();
  17.                 app.Visible = false;
  18.                 app.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;
  19.  
  20.                 docs = app.Documents;
  21.                 doc = docs.Open(ref path, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o);
  22.                 doc.Activate();
  23.  
  24.                 foreach (Word.Range range in doc.StoryRanges)
  25.                 {
  26.                     Word.Find find = range.Find;
  27.                     object findText = "solicitar";
  28.                     object replacText = "Sacramento";
  29.                     object replace = Word.WdReplace.wdReplaceAll;
  30.                     object findWrap = Word.WdFindWrap.wdFindContinue;
  31.  
  32.                     find.Execute(ref findText, ref o, ref o, ref o, ref oFalse, ref o,
  33.                         ref o, ref findWrap, ref o, ref replacText,
  34.                         ref replace, ref o, ref o, ref o, ref o);
  35.  
  36.                     Marshal.FinalReleaseComObject(find);
  37.                     Marshal.FinalReleaseComObject(range);
  38.                 }
  39.  
  40.                 doc.Save();
  41.                 ((Word._Document)doc).Close(ref o, ref o, ref o);
  42.                 app.Quit(ref o, ref o, ref o);
  43.             }
  44.             finally
  45.             {
  46.                 if (doc != null)
  47.                     Marshal.FinalReleaseComObject(doc);
  48.  
  49.                 if (docs != null)
  50.                     Marshal.FinalReleaseComObject(docs);
  51.  
  52.                 if (app != null)
  53.                     Marshal.FinalReleaseComObject(app);
  54.             }
  55.         }
  56. }
__________________
Define tus intereses, se curioso, investiga, comete errores, aprende, practica, mejora, enseña y vuelve a comenzar....

Etiquetas: existente, interop, modificar, word
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 03:24.