1
					
						
						« en: Miércoles 13 de Junio de 2007, 18:38 »
					 
					
					Bien, con este trozo de código he conseguido que funcione, pero no lo llego a entender muy bien, agradecería que alguien con más experiencia me ayudara a entenderlo mejor y buscar posibles mejoras para dar mayor rapidez y asegurar que no se queda nada en memoria, etc..
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using Word = Microsoft.Office.Interop.Word;
namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Word.Application app = new Word.Application();
            // 
            int errors = 0;
          
                if (textBox1.Text.Length > 0)
                {
                    app.Visible = false;
                    object template = Missing.Value;
                    object newTemplate = Missing.Value;
                    object documentType = Missing.Value;
                    object visible = true;
                    Word._Document doc1 = app.Documents.Add(ref template, ref newTemplate, ref documentType, ref visible);
                    doc1.Words.First.InsertBefore(textBox1.Text);
                    Word.ProofreadingErrors spellErrorsColl = doc1.SpellingErrors;
                    errors = spellErrorsColl.Count;
                    object optional = Missing.Value;
                    doc1.CheckSpelling(
                        ref optional, ref optional, ref optional, ref optional, ref optional, ref optional,
                        ref optional, ref optional, ref optional, ref optional, ref optional, ref optional);
                    label1.Text = errors + " Errores corregidos ";
                    object first = 0;
                    object last = doc1.Characters.Count - 1;
                    textBox1.Text = doc1.Range(ref first, ref last).Text;
                }
                
                object saveChanges = false;
                object originalFormat = Missing.Value;
                object routeDocument = Missing.Value;
                app.Application.Quit(ref saveChanges, ref originalFormat, ref routeDocument);
        }
    }
}
Advertencia   1   Ambigüedad entre el método 'Microsoft.Office.Interop.Word._Application.Quit(ref object, ref object, ref object)' 
y el no método 'Microsoft.Office.Interop.Word.ApplicationEvents4_Event.Quit'. 
Se utilizará el grupo de métodos.   C:\PRY_001\WindowsApplication1\WindowsApplication1\Form1.cs   60   33   WindowsApplication1
Además no entiendo muy bien como corregir el Warning que me da.
Desde ya, gracias.