private void ExportaDOC(CompanyInfo empresa)
        {
            object oMissing  = System.Reflection.Missing.Value;
            object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */

            try
            {
                WordExporter.InitWordExporter();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message,
                                moleQule.Face.Resources.Labels.ERROR_TITLE,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

                return;
            }

            Word.Document oDoc = WordExporter.NewDocument();

            //Start Word and create a new document.

            /*Word._Application oWord;
             * Word._Document oDoc;
             * oWord = new Word.Application();
             * oWord.Visible = true;
             * oDoc = oWord.Documents.Add(ref oMissing, ref oMissing,
             *  ref oMissing, ref oMissing);*/

            foreach (Word.Section wordSection in oDoc.Sections)
            {
                wordSection.Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Text = empresa.Name;
                wordSection.Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].PageNumbers.ShowFirstPageNumber = true;
                wordSection.Range.ParagraphFormat.SpaceAfter  = 0;
                wordSection.Range.ParagraphFormat.SpaceBefore = 0;
            }

            //Márgenes (1cm aprox.)
            oDoc.PageSetup.TopMargin    = 15;
            oDoc.PageSetup.BottomMargin = 0;
            oDoc.PageSetup.LeftMargin   = 30;
            oDoc.PageSetup.RightMargin  = 30;

            //Tabla de encabezado
            Word.Table oTable;
            Word.Range wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
            oTable = oDoc.Tables.Add(wrdRng, 5, 4, ref oMissing, ref oMissing);

            oTable.Range.ParagraphFormat.SpaceAfter  = 6;
            oTable.Range.ParagraphFormat.SpaceBefore = 6;

            oTable.Columns[1].Cells.Merge();
            oTable.Borders.Enable           = 1;
            oTable.Borders.InsideLineWidth  = Word.WdLineWidth.wdLineWidth150pt;
            oTable.Borders.OutsideLineWidth = Word.WdLineWidth.wdLineWidth150pt;

            oTable.Columns[2].Cells[1].Merge(oTable.Columns[2].Cells[2]);

            oTable.Columns[1].Width = 108.44F;
            oTable.Columns[3].Width = 81.33F;
            oTable.Columns[4].Width = 81.33F;
            oTable.Columns[2].Width = 271.1F;

            oTable.Rows.Alignment = Word.WdRowAlignment.wdAlignRowCenter;

            string logo = CompanyInfo.GetLogoPath(empresa.Oid);

            if (!File.Exists(logo))
            {
                MessageBox.Show("No se ha encontrado la imagen: " + logo);
            }
            else
            {
                oTable.Cell(1, 1).Range.InlineShapes.AddPicture(logo, ref oMissing, ref oMissing, ref oMissing);
            }
            oTable.Cell(1, 1).VerticalAlignment = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;

            ExamenPrint examen = Entity.GetPrintObject(empresa, string.Empty);

            oTable.Cell(1, 2).Range.Text                 = "HOJA DE PREGUNTAS";
            oTable.Cell(1, 2).Range.Font.Bold            = 1;
            oTable.Cell(1, 2).Range.Font.Size            = 16;
            oTable.Cell(1, 2).VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Cell(1, 2).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[2].Cells[1].Range.Font.Name   = "Arial";

            oTable.Columns[2].Cells[2].Range.Text                 = examen.Modulo;
            oTable.Columns[2].Cells[2].Range.Font.Bold            = 1;
            oTable.Columns[2].Cells[2].Range.Font.Size            = 11;
            oTable.Columns[2].Cells[2].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[2].Cells[2].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[2].Cells[2].Range.Font.Name            = "Arial";

            oTable.Columns[2].Cells[3].Range.Text                 = "CURSO : " + examen.Promocion;
            oTable.Columns[2].Cells[3].Range.Font.Bold            = 1;
            oTable.Columns[2].Cells[3].Range.Font.Size            = 11;
            oTable.Columns[2].Cells[3].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[2].Cells[3].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[2].Cells[3].Range.Font.Name            = "Arial";

            oTable.Columns[2].Cells[4].Range.Text                 = "Deberá responder a las preguntas del examen a continuación de las mismas.";
            oTable.Columns[2].Cells[4].Range.Font.Size            = 11;
            oTable.Columns[2].Cells[4].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[2].Cells[4].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[2].Cells[4].Range.Font.Name            = "Arial";

            oTable.Columns[3].Cells[1].Range.Text                 = "Nº EXAMEN";
            oTable.Columns[3].Cells[1].Range.Font.Bold            = 1;
            oTable.Columns[3].Cells[1].Range.Font.Size            = 11;
            oTable.Columns[3].Cells[1].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[3].Cells[1].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[3].Cells[1].Range.Font.Name            = "Arial";

            oTable.Columns[3].Cells[2].Range.Text                 = "FECHA";
            oTable.Columns[3].Cells[2].Range.Font.Bold            = 1;
            oTable.Columns[3].Cells[2].Range.Font.Size            = 11;
            oTable.Columns[3].Cells[2].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[3].Cells[2].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[3].Cells[2].Range.Font.Name            = "Arial";

            oTable.Columns[3].Cells[3].Range.Text                 = "TIPO EXAMEN";
            oTable.Columns[3].Cells[3].Range.Font.Bold            = 1;
            oTable.Columns[3].Cells[3].Range.Font.Size            = 11;
            oTable.Columns[3].Cells[3].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[3].Cells[3].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[3].Cells[3].Range.Font.Name            = "Arial";

            oTable.Columns[3].Cells[4].Range.Text                 = "Nº PREGUNTAS";
            oTable.Columns[3].Cells[4].Range.Font.Bold            = 1;
            oTable.Columns[3].Cells[4].Range.Font.Size            = 11;
            oTable.Columns[3].Cells[4].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[3].Cells[4].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[3].Cells[4].Range.Font.Name            = "Arial";

            oTable.Columns[3].Cells[5].Range.Text                 = "TIEMPO";
            oTable.Columns[3].Cells[5].Range.Font.Bold            = 1;
            oTable.Columns[3].Cells[5].Range.Font.Size            = 11;
            oTable.Columns[3].Cells[5].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[3].Cells[5].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[3].Cells[5].Range.Font.Name            = "Arial";

            oTable.Columns[4].Cells[1].Range.Text                 = examen.Numero.ToString().Trim();
            oTable.Columns[4].Cells[1].Range.Font.Size            = 11;
            oTable.Columns[4].Cells[1].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[4].Cells[1].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[4].Cells[1].Range.Font.Name            = "Arial";

            oTable.Columns[4].Cells[2].Range.Text                 = examen.FechaExamen.ToShortDateString().Trim();
            oTable.Columns[4].Cells[2].Range.Font.Size            = 11;
            oTable.Columns[4].Cells[2].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[4].Cells[2].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[4].Cells[2].Range.Font.Name            = "Arial";

            oTable.Columns[4].Cells[3].Range.Text                 = examen.Tipo.Trim();
            oTable.Columns[4].Cells[3].Range.Font.Size            = 11;
            oTable.Columns[4].Cells[3].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[4].Cells[3].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[4].Cells[3].Range.Font.Name            = "Arial";

            oTable.Columns[4].Cells[4].Range.Text                 = examen.NPreguntas.ToString().Trim();
            oTable.Columns[4].Cells[4].Range.Font.Size            = 11;
            oTable.Columns[4].Cells[4].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[4].Cells[4].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[4].Cells[4].Range.Font.Name            = "Arial";

            oTable.Columns[4].Cells[5].Range.Font.Name            = "Arial";
            oTable.Columns[4].Cells[5].Range.Font.Size            = 11;
            oTable.Columns[4].Cells[5].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
            oTable.Columns[4].Cells[5].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            oTable.Columns[4].Cells[5].Range.Text = examen.Duracion.ToShortTimeString().Trim();

            ////Add some text after the table.
            Word.Paragraph oParaAux;
            object         oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;

            oParaAux            = oDoc.Content.Paragraphs.Add(ref oRng);
            oParaAux.Range.Text = string.Empty;
            oParaAux.Range.InsertParagraph();

            //Nombre y apellidos
            Word.Paragraph oPara1;
            oPara1                 = oDoc.Content.Paragraphs.Add(ref oMissing);
            oPara1.Range.Text      = "NOMBRE Y APELLIDOS:";
            oPara1.Range.Font.Size = 12;
            oPara1.Range.Font.Name = "Arial";
            oPara1.Range.InsertParagraphAfter();
            oPara1.Range.InsertParagraphBefore();

            //DNI/NIE, FIRMA
            Word.Paragraph oPara2;
            oPara2                 = oDoc.Content.Paragraphs.Add(ref oMissing);
            oPara2.Range.Text      = "DNI/NIE:                                                           FIRMA:";
            oPara2.Range.Font.Size = 12;
            oPara2.Range.Font.Name = "Arial";
            oPara2.Range.InsertParagraphAfter();
            oPara2.Range.InsertParagraphBefore();

            PreguntaList lista_preguntas = null;

            //Origen de las preguntas en función de si el examen está emitido o no
            if (_entity.Emitido)
            {
                lista_preguntas = PreguntaList.GetList(_entity.PreguntaExamenes);
            }
            else
            {
                lista_preguntas = _preguntas;
            }

            if (lista_preguntas != null)
            {
                int          i = 1;
                PreguntaInfo item;

                foreach (PreguntaExamenInfo pex in _entity.PreguntaExamenes)
                {
                    item = lista_preguntas.GetItem(pex.OidPregunta);

                    /*if (_preguntas_examen != null)
                     * {
                     *  int i = 1;
                     *
                     *  foreach (Pregunta_Examen preg in _preguntas_examen)
                     *  {
                     *      Pregunta item = _preguntas.GetItem(preg.OidPregunta);*/

                    //Para cada pregunta se inserta una tabla
                    wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                    Word.Range newRng        = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                    int        paginas_antes = (int)(oTable.Range.get_Information(Word.WdInformation.wdNumberOfPagesInDocument));
                    oTable = oDoc.Tables.Add(wrdRng, 2, 3, ref oMissing, ref oMissing);

                    oTable.Rows.HeightRule = Word.WdRowHeightRule.wdRowHeightAuto;

                    oTable.Columns[1].Width                      = 30;
                    oTable.Cell(1, 1).Range.Text                 = i.ToString();
                    oTable.Cell(1, 1).Range.Font.Size            = 10;
                    oTable.Cell(1, 1).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                    oTable.Cell(1, 1).Range.Font.Bold            = 1;
                    oTable.Cell(1, 1).Range.Font.Name            = "Arial";

                    oTable.Cell(1, 2).Merge(oTable.Columns[3].Cells[1]);
                    oTable.Cell(1, 2).Width                      = 510;
                    oTable.Cell(1, 2).Range.Text                 = item.Texto;
                    oTable.Cell(1, 2).Range.Font.Size            = 10;
                    oTable.Cell(1, 2).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphJustify;
                    oTable.Cell(1, 2).Range.Font.Bold            = 1;
                    oTable.Cell(1, 2).Range.Font.Name            = "Arial";

                    oTable.Cell(2, 2).Merge(oTable.Cell(2, 3));
                    oTable.Cell(2, 1).Merge(oTable.Cell(2, 2));
                    oTable.Cell(2, 1).Width = 540;

                    if (item.Imagen != string.Empty)
                    {
                        string path = item.ImagenWithPath;

                        if (File.Exists(path))
                        {
                            oTable.Cell(2, 1).Range.InlineShapes.AddPictureBullet(path, ref oMissing);
                            oTable.Cell(2, 1).VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                            oTable.Cell(2, 1).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                        }
                        else
                        {
                            oTable.Rows[2].Delete();
                        }
                    }
                    else
                    {
                        oTable.Rows[2].Delete();
                    }

                    ////Add some text after the table.
                    oRng                = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                    oParaAux            = oDoc.Content.Paragraphs.Add(ref oRng);
                    oParaAux.Range.Text = string.Empty;
                    oParaAux.Range.InsertParagraph();

                    int paginas_despues = (int)(oParaAux.Range.get_Information(Word.WdInformation.wdNumberOfPagesInDocument));
                    if (paginas_antes < paginas_despues)
                    {
                        newRng.InsertBreak(ref oMissing);
                    }

                    i++;
                }
            }
            else
            {
                foreach (PreguntaExamenInfo item in Entity.PreguntaExamenes)
                {
                    //Para cada pregunta se inserta una tabla
                    wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                    Word.Range newRng        = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                    int        paginas_antes = (int)(oTable.Range.get_Information(Word.WdInformation.wdNumberOfPagesInDocument));
                    oTable = oDoc.Tables.Add(wrdRng, 2, 3, ref oMissing, ref oMissing);

                    oTable.Rows.HeightRule = Word.WdRowHeightRule.wdRowHeightAuto;

                    oTable.Columns[1].Width                      = 30;
                    oTable.Cell(1, 1).Range.Text                 = item.Orden.ToString();
                    oTable.Cell(1, 1).Range.Font.Size            = 10;
                    oTable.Cell(1, 1).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                    oTable.Cell(1, 1).Range.Font.Bold            = 1;
                    oTable.Cell(1, 1).Range.Font.Name            = "Arial";

                    oTable.Cell(1, 2).Merge(oTable.Columns[3].Cells[1]);
                    oTable.Cell(1, 2).Width                      = 510;
                    oTable.Cell(1, 2).Range.Text                 = item.Texto;
                    oTable.Cell(1, 2).Range.Font.Size            = 10;
                    oTable.Cell(1, 2).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphJustify;
                    oTable.Cell(1, 2).Range.Font.Bold            = 1;
                    oTable.Cell(1, 2).Range.Font.Name            = "Arial";

                    oTable.Cell(2, 2).Merge(oTable.Cell(2, 3));
                    oTable.Cell(2, 1).Merge(oTable.Cell(2, 2));
                    oTable.Cell(2, 1).Width = 540;

                    if (item.Imagen != string.Empty)
                    {
                        /*string path = Images.GetRootPath() + PreguntaExamenInfo.GetImagenesPath() +
                         *  item.OidExamen.ToString("00000") + "\\" + item.Imagen;*/
                        string path = item.ImagenWithPath;

                        if (File.Exists(path))
                        {
                            oTable.Cell(2, 1).Range.InlineShapes.AddPictureBullet(path, ref oMissing);
                            oTable.Cell(2, 1).VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                            oTable.Cell(2, 1).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                        }
                        else
                        {
                            oTable.Rows[2].Delete();
                        }
                    }
                    else
                    {
                        oTable.Rows[2].Delete();
                    }

                    ////Add some text after the table.
                    oRng                = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                    oParaAux            = oDoc.Content.Paragraphs.Add(ref oRng);
                    oParaAux.Range.Text = string.Empty;
                    oParaAux.Range.InsertParagraph();

                    int paginas_despues = (int)(oParaAux.Range.get_Information(Word.WdInformation.wdNumberOfPagesInDocument));
                    if (paginas_antes < paginas_despues)
                    {
                        newRng.InsertBreak(ref oMissing);
                    }
                }
            }

            WordExporter.Close();
        }
        private void ExportaDOC(CompanyInfo empresa)
        {
            object      oMissing  = System.Reflection.Missing.Value;
            object      oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */
            ExamenPrint examen    = null;

            try
            {
                WordExporter.InitWordExporter();

                examen = Entity.GetPrintObject(empresa, string.Empty);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message,
                                moleQule.Face.Resources.Labels.ERROR_TITLE,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            PgMng.Reset(_entity.PreguntaExamenes.Count + 7, 1, Resources.Messages.LOADING_DATA, this);

            try
            {
                Word.Document oDoc = WordExporter.NewDocument();
                PgMng.Grow();

                foreach (Word.Section wordSection in oDoc.Sections)
                {
                    wordSection.Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary]
                    .Range.Text = empresa.Name;
                    wordSection.Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary]
                    .Range.Borders.DistanceFromTop = 10;
                    wordSection.Footers[
                        Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].PageNumbers.ShowFirstPageNumber = true;
                    wordSection.Range.ParagraphFormat.SpaceAfter  = 0;
                    wordSection.Range.ParagraphFormat.SpaceBefore = 0;
                }
                PgMng.Grow();

                //Márgenes (1cm aprox.)
                oDoc.PageSetup.TopMargin    = 15;
                oDoc.PageSetup.BottomMargin = 0;
                oDoc.PageSetup.LeftMargin   = 30;
                oDoc.PageSetup.RightMargin  = 30;

                //Tabla de encabezado
                Word.Table oTable;
                Word.Range wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                oTable = oDoc.Tables.Add(wrdRng, 5, 4, ref oMissing, ref oMissing);

                oTable.Range.ParagraphFormat.SpaceAfter  = 6;
                oTable.Range.ParagraphFormat.SpaceBefore = 6;

                oTable.Columns[1].Cells.Merge();
                oTable.Borders.Enable           = 1;
                oTable.Borders.InsideLineWidth  = Word.WdLineWidth.wdLineWidth150pt;
                oTable.Borders.OutsideLineWidth = Word.WdLineWidth.wdLineWidth150pt;

                oTable.Columns[2].Cells[1].Merge(oTable.Columns[2].Cells[2]);

                oTable.Columns[1].Width = 108.44F;
                oTable.Columns[3].Width = 81.33F;
                oTable.Columns[4].Width = 81.33F;
                oTable.Columns[2].Width = 271.1F;

                oTable.Rows.Alignment = Word.WdRowAlignment.wdAlignRowCenter;
                PgMng.Grow();

                string logo = CompanyInfo.GetLogoPath(empresa.Oid);
                if (!File.Exists(logo))
                {
                    MessageBox.Show("No se ha encontrado la imagen: " + logo);
                }
                else
                {
                    oTable.Cell(1, 1).Range.InlineShapes.AddPicture(logo, ref oMissing, ref oMissing, ref oMissing);
                }
                oTable.Cell(1, 1).VerticalAlignment = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                PgMng.Grow();

                oTable.Cell(1, 2).Range.Text                 = "HOJA DE PREGUNTAS";
                oTable.Cell(1, 2).Range.Font.Bold            = 1;
                oTable.Cell(1, 2).Range.Font.Size            = 16;
                oTable.Cell(1, 2).VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Cell(1, 2).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[2].Cells[1].Range.Font.Name   = "Arial";

                oTable.Columns[2].Cells[2].Range.Text                 = examen.Modulo;
                oTable.Columns[2].Cells[2].Range.Font.Bold            = 1;
                oTable.Columns[2].Cells[2].Range.Font.Size            = 11;
                oTable.Columns[2].Cells[2].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[2].Cells[2].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[2].Cells[2].Range.Font.Name            = "Arial";

                oTable.Columns[2].Cells[3].Range.Text                 = "CURSO : " + examen.Promocion;
                oTable.Columns[2].Cells[3].Range.Font.Bold            = 1;
                oTable.Columns[2].Cells[3].Range.Font.Size            = 11;
                oTable.Columns[2].Cells[3].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[2].Cells[3].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[2].Cells[3].Range.Font.Name            = "Arial";

                oTable.Columns[2].Cells[4].Range.Text =
                    "Deberá utilizar la plantilla que se le entregará para responder a las preguntas del examen.";
                oTable.Columns[2].Cells[4].Range.Font.Size            = 11;
                oTable.Columns[2].Cells[4].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[2].Cells[4].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[2].Cells[4].Range.Font.Name            = "Arial";

                oTable.Columns[3].Cells[1].Range.Text                 = "Nº EXAMEN";
                oTable.Columns[3].Cells[1].Range.Font.Bold            = 1;
                oTable.Columns[3].Cells[1].Range.Font.Size            = 11;
                oTable.Columns[3].Cells[1].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[3].Cells[1].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[3].Cells[1].Range.Font.Name            = "Arial";

                oTable.Columns[3].Cells[2].Range.Text                 = "FECHA";
                oTable.Columns[3].Cells[2].Range.Font.Bold            = 1;
                oTable.Columns[3].Cells[2].Range.Font.Size            = 11;
                oTable.Columns[3].Cells[2].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[3].Cells[2].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[3].Cells[2].Range.Font.Name            = "Arial";

                oTable.Columns[3].Cells[3].Range.Text                 = "TIPO EXAMEN";
                oTable.Columns[3].Cells[3].Range.Font.Bold            = 1;
                oTable.Columns[3].Cells[3].Range.Font.Size            = 11;
                oTable.Columns[3].Cells[3].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[3].Cells[3].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[3].Cells[3].Range.Font.Name            = "Arial";

                oTable.Columns[3].Cells[4].Range.Text                 = "Nº PREGUNTAS";
                oTable.Columns[3].Cells[4].Range.Font.Bold            = 1;
                oTable.Columns[3].Cells[4].Range.Font.Size            = 11;
                oTable.Columns[3].Cells[4].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[3].Cells[4].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[3].Cells[4].Range.Font.Name            = "Arial";

                oTable.Columns[3].Cells[5].Range.Text                 = "TIEMPO";
                oTable.Columns[3].Cells[5].Range.Font.Bold            = 1;
                oTable.Columns[3].Cells[5].Range.Font.Size            = 11;
                oTable.Columns[3].Cells[5].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[3].Cells[5].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[3].Cells[5].Range.Font.Name            = "Arial";

                oTable.Columns[4].Cells[1].Range.Text                 = examen.Numero.ToString().Trim();
                oTable.Columns[4].Cells[1].Range.Font.Size            = 11;
                oTable.Columns[4].Cells[1].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[4].Cells[1].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[4].Cells[1].Range.Font.Name            = "Arial";

                oTable.Columns[4].Cells[2].Range.Text                 = examen.FechaExamen.ToShortDateString().Trim();
                oTable.Columns[4].Cells[2].Range.Font.Size            = 11;
                oTable.Columns[4].Cells[2].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[4].Cells[2].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[4].Cells[2].Range.Font.Name            = "Arial";

                oTable.Columns[4].Cells[3].Range.Text                 = examen.Tipo.Trim();
                oTable.Columns[4].Cells[3].Range.Font.Size            = 11;
                oTable.Columns[4].Cells[3].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[4].Cells[3].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[4].Cells[3].Range.Font.Name            = "Arial";

                oTable.Columns[4].Cells[4].Range.Text                 = examen.NPreguntas.ToString().Trim();
                oTable.Columns[4].Cells[4].Range.Font.Size            = 11;
                oTable.Columns[4].Cells[4].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[4].Cells[4].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[4].Cells[4].Range.Font.Name            = "Arial";

                oTable.Columns[4].Cells[5].Range.Font.Name            = "Arial";
                oTable.Columns[4].Cells[5].Range.Font.Size            = 11;
                oTable.Columns[4].Cells[5].VerticalAlignment          = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                oTable.Columns[4].Cells[5].Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                oTable.Columns[4].Cells[5].Range.Text = examen.Duracion.ToShortTimeString().Trim();
                PgMng.Grow();

                ////Add some text after the table.
                Word.Paragraph oParaAux;
                object         oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                oParaAux            = oDoc.Content.Paragraphs.Add(ref oRng);
                oParaAux.Range.Text = string.Empty;
                oParaAux.Range.InsertParagraph();

                //Nombre y apellidos
                Word.Paragraph oPara1;
                oPara1                 = oDoc.Content.Paragraphs.Add(ref oMissing);
                oPara1.Range.Text      = "NOMBRE Y APELLIDOS:";
                oPara1.Range.Font.Size = 12;
                oPara1.Range.Font.Name = "Arial";
                oPara1.Range.InsertParagraphAfter();
                oPara1.Range.InsertParagraphBefore();

                //DNI/NIE, FIRMA
                Word.Paragraph oPara2;
                oPara2                 = oDoc.Content.Paragraphs.Add(ref oMissing);
                oPara2.Range.Text      = "DNI/NIE:                                                           FIRMA:";
                oPara2.Range.Font.Size = 12;
                oPara2.Range.Font.Name = "Arial";
                oPara2.Range.InsertParagraphAfter();
                oPara2.Range.InsertParagraphBefore();
                PgMng.Grow();

                PreguntaList lista_preguntas = null;

                //Origen de las preguntas en función de si el examen está emitido o no
                if (_entity.Emitido)
                {
                    lista_preguntas = PreguntaList.GetList(_entity.PreguntaExamenes);
                }
                else
                {
                    lista_preguntas = _preguntas;
                }

                if (lista_preguntas != null)
                {
                    int          i = 1;
                    PreguntaInfo item;

                    foreach (PreguntaExamenInfo pex in _entity.PreguntaExamenes)
                    {
                        item = lista_preguntas.GetItem(pex.OidPregunta);

                        //Para cada pregunta se inserta una tabla
                        wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                        Word.Range newRng        = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                        int        paginas_antes = (int)(oTable.Range.get_Information(
                                                             Word.WdInformation.wdNumberOfPagesInDocument));
                        oTable = oDoc.Tables.Add(wrdRng, 5, 3, ref oMissing, ref oMissing);

                        oTable.Rows.HeightRule = Word.WdRowHeightRule.wdRowHeightAuto;

                        oTable.Columns[1].Width                      = 30;
                        oTable.Cell(1, 1).Range.Text                 = i.ToString();
                        oTable.Cell(1, 1).Range.Font.Size            = 10;
                        oTable.Cell(1, 1).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                        oTable.Cell(1, 1).Range.Font.Bold            = 1;
                        oTable.Cell(1, 1).Range.Font.Name            = "Arial";

                        oTable.Cell(1, 2).Merge(oTable.Columns[3].Cells[1]);
                        oTable.Cell(1, 2).BottomPadding              = 8;
                        oTable.Cell(1, 2).Width                      = 510;
                        oTable.Cell(1, 2).Range.Text                 = item.Texto;
                        oTable.Cell(1, 2).Range.Font.Size            = 10;
                        oTable.Cell(1, 2).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphJustify;
                        oTable.Cell(1, 2).Range.Font.Bold            = 1;
                        oTable.Cell(1, 2).Range.Font.Name            = "Arial";

                        oTable.Cell(2, 2).Merge(oTable.Cell(2, 3));
                        oTable.Cell(2, 1).Merge(oTable.Cell(2, 2));
                        oTable.Cell(2, 1).Width = 540;

                        oTable.Cell(3, 2).Width                      = 20;
                        oTable.Cell(3, 2).Range.Text                 = "A";
                        oTable.Cell(3, 2).Range.Font.Size            = 10;
                        oTable.Cell(3, 2).Range.Paragraphs.Alignment =
                            Word.WdParagraphAlignment.wdAlignParagraphCenter;
                        oTable.Cell(3, 2).Range.Font.Name = "Arial";

                        oTable.Cell(4, 2).Width                      = 20;
                        oTable.Cell(4, 2).Range.Text                 = "B";
                        oTable.Cell(4, 2).Range.Font.Size            = 10;
                        oTable.Cell(4, 2).Range.Paragraphs.Alignment =
                            Word.WdParagraphAlignment.wdAlignParagraphCenter;
                        oTable.Cell(4, 2).Range.Font.Name = "Arial";

                        oTable.Cell(5, 2).Width                      = 20;
                        oTable.Cell(5, 2).Range.Text                 = "C";
                        oTable.Cell(5, 2).Range.Font.Size            = 10;
                        oTable.Cell(5, 2).Range.Paragraphs.Alignment =
                            Word.WdParagraphAlignment.wdAlignParagraphCenter;
                        oTable.Cell(5, 2).Range.Font.Name = "Arial";

                        foreach (RespuestaInfo obj in item.Respuestas)
                        {
                            switch (obj.Opcion)
                            {
                            case "A":
                            {
                                oTable.Cell(3, 3).Width                      = 490;
                                oTable.Cell(3, 3).Range.Text                 = obj.Texto;
                                oTable.Cell(3, 3).Range.Font.Size            = 10;
                                oTable.Cell(3, 3).Range.Paragraphs.Alignment =
                                    Word.WdParagraphAlignment.wdAlignParagraphJustify;
                                oTable.Cell(3, 3).Range.Font.Name = "Arial";
                                break;
                            }

                            case "B":
                            {
                                oTable.Cell(4, 3).Width                      = 490;
                                oTable.Cell(4, 3).Range.Text                 = obj.Texto;
                                oTable.Cell(4, 3).Range.Font.Size            = 10;
                                oTable.Cell(4, 3).Range.Paragraphs.Alignment =
                                    Word.WdParagraphAlignment.wdAlignParagraphJustify;
                                oTable.Cell(4, 3).Range.Font.Name = "Arial";
                                break;
                            }

                            case "C":
                            {
                                oTable.Cell(5, 3).Width                      = 490;
                                oTable.Cell(5, 3).Range.Text                 = obj.Texto;
                                oTable.Cell(5, 3).Range.Font.Size            = 10;
                                oTable.Cell(5, 3).Range.Paragraphs.Alignment =
                                    Word.WdParagraphAlignment.wdAlignParagraphJustify;
                                oTable.Cell(5, 3).Range.Font.Name = "Arial";
                                break;
                            }
                            }
                        }

                        if (item.Imagen != string.Empty)
                        {
                            string path = _entity.Emitido ?
                                          Library.Application.AppController.FOTOS_PREGUNTAS_EXAMEN_PATH + _entity.Oid.ToString("00000") + "\\" + item.Imagen :
                                          item.ImagenWithPath;

                            if (File.Exists(path))
                            {
                                oTable.Cell(2, 1).Range.InlineShapes.AddPictureBullet(path, ref oMissing);
                                oTable.Cell(2, 1).VerticalAlignment =
                                    Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                                oTable.Cell(2, 1).Range.Paragraphs.Alignment =
                                    Word.WdParagraphAlignment.wdAlignParagraphCenter;
                            }
                            else
                            {
                                MessageBox.Show("No se ha encontrado la imagen: " + path);
                                oTable.Rows[2].Delete();
                            }
                        }
                        else
                        {
                            oTable.Rows[2].Delete();
                        }

                        ////Add some text after the table.
                        oRng                = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                        oParaAux            = oDoc.Content.Paragraphs.Add(ref oRng);
                        oParaAux.Range.Text = string.Empty;
                        oParaAux.Range.InsertParagraph();

                        int paginas_despues = (int)(oParaAux.Range.get_Information(
                                                        Word.WdInformation.wdNumberOfPagesInDocument));
                        if (paginas_antes < paginas_despues)
                        {
                            newRng.InsertBreak(ref oMissing);
                        }

                        i++;
                    }
                    PgMng.Grow();
                    oDoc.Close(Microsoft.Office.Interop.Word.WdSaveOptions.wdPromptToSaveChanges,
                               Microsoft.Office.Interop.Word.WdOriginalFormat.wdPromptUser,
                               true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message,
                                moleQule.Face.Resources.Labels.ERROR_TITLE,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            finally
            {
                WordExporter.Close();
                PgMng.FillUp();
            }
        }