当前位置: 首页>>代码示例>>C#>>正文


C# Document.SaveAs2方法代码示例

本文整理汇总了C#中Microsoft.Office.Interop.Word.Document.SaveAs2方法的典型用法代码示例。如果您正苦于以下问题:C# Document.SaveAs2方法的具体用法?C# Document.SaveAs2怎么用?C# Document.SaveAs2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Office.Interop.Word.Document的用法示例。


在下文中一共展示了Document.SaveAs2方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateReportCA


//.........这里部分代码省略.........
                            tickets_planovie++;
                        }
                        // если не плановые, то увеличиваем обращения
                        else tickets_obrascheniya++;
                        // переходим на след строку в документе
                        row_to_insert_tickets++;
                    }
                    // если строки не равны, то объеденияем ячейки
                    if (!(row_start_merge == row_to_insert_tickets - 1))
                    {
                        word_table2.Cell(row_start_merge, 1).Merge(word_table2.Cell(row_to_insert_tickets - 1, 1));
                    }
                    // переходим к след дню
                    row_start_merge = row_to_insert_tickets;
                    number_of_massive++;
                    this.Invoke((Action)delegate
                    {
                        tsStatusLabel.Text = "Заполнение документа";
                        tsProgressBar.Maximum = tickets.Length;
                        tsProgressBar.Value++;
                    });
                }
                // объявляем переменную для первой таблицы, в которую пишутся итоги
                word_table1 = word_doc.Tables[1];
                // берем все месячные работы из начала документа
                int planovie_calendar = ((int.Parse(work_days) * count_work_days) + (int.Parse(month_in_days) * count_month_in_days));
                // пишем кол-во обращений
                word_table1.Rows[2].Cells[2].Range.Text = tickets_obrascheniya.ToString();
                // пишем кол-во плановых работ
                word_table1.Rows[3].Cells[2].Range.Text = (planovie_calendar + tickets_planovie).ToString();
                // пишем общее кол-во заявок
                word_table1.Rows[4].Cells[2].Range.Text = (planovie_calendar + tickets_planovie + tickets_obrascheniya).ToString();
                // цвет для закраски чередующихся строк
                Color color_background = Color.FromArgb(222, 234, 246);
                // приводим цвет к совместимому с Word
                var word_background_color = (Microsoft.Office.Interop.Word.WdColor)(color_background.R + 0x100 * color_background.G + 0x10000 * color_background.B); ;
                // закрашиваем каждую вторую строку
                while (row_to_color < row_to_insert_tickets)
                {
                    word_table2.Cell(row_to_color, 2).Shading.BackgroundPatternColor = word_background_color;
                    word_table2.Cell(row_to_color, 3).Shading.BackgroundPatternColor = word_background_color;
                    word_table2.Cell(row_to_color, 4).Shading.BackgroundPatternColor = word_background_color;
                    row_to_color += 2;
                }

                this.Invoke((Action)delegate
                {
                    tsProgressBar.Value = 0;
                    tsStatusLabel.Text = "Готово!";
                    // окно сохранения документа
                    SaveFileDialog sfd = new SaveFileDialog();
                    // расширение по умеолчанию
                    sfd.DefaultExt = "docx";
                    // автоматом добавлять расширение
                    sfd.AddExtension = true;
                    // фильтр выводимых файлов в окне
                    sfd.Filter = "Документ Word(*.docx)|*.docx";
                    // фильтр по умолчанию
                    sfd.FilterIndex = 1;
                    // задаем имя документу
                    sfd.FileName = "Еженедельный-Месячный отчет " + StringPeriod(false);
                    // при нажатии "ОК"
                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        // сохраняем документ
                        word_doc.SaveAs2(sfd.FileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                        // выводим окно с сообщением
                        MessageBox.Show("Готово!\nСхоранено в "+sfd.FileName);
                        // закрываем документ с сохранием
                        word_doc.Close(Word.WdSaveOptions.wdSaveChanges, Type.Missing, Type.Missing);
                        // закрываем приложение Word
                        word_app.Quit(Type.Missing, Type.Missing, Type.Missing);
                        // прибиваем процесс Word'a
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(word_app);
                        // сбрасываем ссылки на Word
                        word_doc = null;
                        word_app = null;
                        // пробуем удалить из памяти лишнее
                        GC.Collect();
                    }
                    // при любом другом действии
                    else
                    {
                        // закрываем документ без сохранения
                        word_doc.Close(Word.WdSaveOptions.wdDoNotSaveChanges, Type.Missing, Type.Missing);
                        // закрываем приложение без сохранения
                        word_app.Quit(Word.WdSaveOptions.wdDoNotSaveChanges, Type.Missing, Type.Missing);
                        // убаваем процесс
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(word_app);
                        // сбрасываем ссылки
                        word_doc = null;
                        word_app = null;
                        // запуск сборщика мусора
                        GC.Collect();
                    }
                });


            });
        }
开发者ID:dmitriyq,项目名称:report-generator,代码行数:101,代码来源:MainFormMonth.cs

示例2: pasarPrimerosDatosAWord


//.........这里部分代码省略.........

                List<Word.Shape> lst = new List<Word.Shape>();


                #region insertar en la primera plantilla de word
                foreach (Word.Shape sh in doc.Shapes)
                    if (sh.Type.ToString() == "msoTextBox")
                    {
                        while (sh.Name.Contains("\n"))
                            sh.Name = sh.Name.Replace("\n", "");
                        lst.Add(sh);
                    }

                foreach (Control ctr in gb_CamposAdicionales.Controls)
                {
                    if (ctr.GetType() == typeof(TextBox))
                    {
                        foreach (Word.Shape sh in lst)
                        {
                            if (ctr.Name == sh.Name.Trim())
                            {
                                sh.TextFrame.TextRange.Text = ctr.Text;
                            }
                        }
                    }
                }
                foreach (Control cbox in gb_CamposAdicionales.Controls.OfType<ComboBox>())
                {
                    if (diccionario_propiedadesEtq.ContainsKey(cbox.Name))
                    {
                        if (diccionario_propiedadesEtq[cbox.Name] == "Etiqueta.Direccion")
                        {
                            foreach (Word.Shape sh in lst)
                            {
                                if (cbox.Name == sh.Name.Trim())
                                {
                                    sh.TextFrame.TextRange.Text = etq.Direccion;
                                }
                            }
                        }
                        else if (diccionario_propiedadesEtq[cbox.Name] == "Etiqueta.Embarque")
                        {
                            foreach (Word.Shape sh in lst)
                            {
                                if (cbox.Name == sh.Name.Trim())
                                {
                                    sh.TextFrame.TextRange.Text = etq.Embarque;
                                }
                            }
                        }

                    }
                    else //en este caso estamos hablando del comboBox de unidades de corte 
                    {
                        foreach (Control txtCorte in gb_CamposAdicionales.Controls.OfType<TextBox>())
                        {
                            if (txtCorte.Name != nombreCorte)
                                continue;
                            else
                            {
                                foreach (Word.Shape sh in lst)
                                    if (txtCorte.Name == sh.Name.Trim())
                                    {
                                        etq.Corte = txtCorte.Text + " " + cbox.Text;
                                        sh.TextFrame.TextRange.Text = etq.Corte;
                                    }
                                        
                            }
                        }
                            
                        
                    }
                }

                foreach (Control dt in gb_CamposAdicionales.Controls.OfType<DateTimePicker>())
                {
                    foreach (Word.Shape sh in lst)
                    {
                        if (dt.Name == sh.Name.Trim())
                        {
                            sh.TextFrame.TextRange.Text = dt.Text;
                        }
                    }
                }
                

                #endregion

                //guardamos como plantilla de etiqueta actual
                doc.SaveAs2(@rutasEnModAdmin.RutaDePlantillas + "/temp_EtiquetaActual.docx");
                doc.Saved = true;
                ((Microsoft.Office.Interop.Word._Document)doc).Close();
                return 1;
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
                return 0;
            }
        }
开发者ID:GeMaths,项目名称:etiquetasPMM,代码行数:101,代码来源:EtiquetasPedidosMostrador.cs

示例3: GetReport

        public string GetReport()
        {
            try
            {
                _wordApp = new Word.Application();
                _doc = _wordApp.Documents.Add(_templateWordPath);

                _doc.Bookmarks["Адрес"].Range.Text = Address;
                _doc.Bookmarks["Дата"].Range.Text = Date.ToShortDateString();
                _doc.Bookmarks["Директор"].Range.Text = Director;
                _doc.Bookmarks["НаименованиеПредприятия"].Range.Text = Organization;
                _doc.Bookmarks["ОтФИО"].Range.Text = string.Format("{0} {1}. {2}.", LastName, Name.Substring(0, 1), MiddleName.Substring(0, 1));
                _doc.Bookmarks["ПаспортВыдан"].Range.Text = string.Format("{0} {1} г.", PassportIssuedBy, PassportIssuedDate.ToShortDateString());
                _doc.Bookmarks["ПаспортНомер"].Range.Text = PassportNumber;
                _doc.Bookmarks["ПаспортСерия"].Range.Text = PassportSeries;
                _doc.Bookmarks["Телефон"].Range.Text = Phone;
                _doc.Bookmarks["Услуга"].Range.Text = Service;
                _doc.Bookmarks["ФИО"].Range.Text = string.Format("{0} {1} {2}", LastName, Name, MiddleName);

                _doc.SaveAs2(FileName: _documnetSavePath, FileFormat: Word.WdSaveFormat.wdFormatPDF);

                return _documnetSavePath;
            }
            catch (Exception)
            {
            }
            finally
            {
                _doc.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
                _wordApp.Quit(Word.WdSaveOptions.wdDoNotSaveChanges);
            }
            return null;
        }
开发者ID:IvanNkl,项目名称:PMKSite,代码行数:33,代码来源:StatementReport.cs

示例4: datosaword2


//.........这里部分代码省略.........
                                            string caadenadireccion = "", cadenaanterior = "";
                                            if (c1.datocampo == null)
                                            {
                                                s.TextFrame.TextRange.Text = "";
                                            }
                                            else
                                            {
                                                if (c1.datocampo.Contains("|"))
                                                {
                                                    separadordireccion = c1.datocampo.Split(new string[] { "|" }, StringSplitOptions.None);
                                                    foreach (string str in separadordireccion)
                                                    {
                                                        if (caadenadireccion == "")
                                                        {
                                                            cadenaanterior = str.Remove(0, 4);
                                                            caadenadireccion = cadenaanterior;
                                                        }
                                                        else
                                                            caadenadireccion = caadenadireccion + "\n" + str.Remove(0, 1);
                                                    }
                                                }
                                                else
                                                {
                                                    if (c1.datocampo == "")
                                                        caadenadireccion = "";
                                                    else
                                                        caadenadireccion = c1.datocampo.Remove(0, 4);
                                                }
                                                s.TextFrame.TextRange.Text = caadenadireccion;
                                            }
                                            bandera = true;
                                            break;
                                        }
                                        else
                                        {
                                            s.TextFrame.TextRange.Text = c1.datocampo;
                                            bandera = true;
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        s.TextFrame.TextRange.Text = c1.datocampo;
                                        bandera = true;
                                        break;
                                    }
                                }
                            }
                            if (bandera)
                                continue;
                            if (s.TextFrame.TextRange.Text.Contains("PALLET"))
                            {
                                if (cbx_PAQUETE.Checked)
                                {
                                    if (etq.IdiomaETQ == 2)
                                        s.TextFrame.TextRange.Text = s.TextFrame.TextRange.Text.Replace("PALLET", "PACKAGE");
                                    if (etq.IdiomaETQ == 1)
                                        s.TextFrame.TextRange.Text = s.TextFrame.TextRange.Text.Replace("PALLET", "PAQUETE");
                                }
                                continue;
                            }
                        }
                    }
                    foreach (CamposCodigos cmp in ListaCodigosBaseDeDatos)
                    {
                        string nombrecampo = cmp.nombrecodigo.Replace("bcd", "txt");
                        foreach (Campos camps in ListaFinal)
                        {
                            if (camps.nombrecampo == nombrecampo)
                            {
                                CampoCodigo.nombrecodigo = cmp.nombrecodigo;
                                CampoCodigo.datocodigo = camps.datocampo;
                                CampoCodigo.tipocodigo = cmp.tipocodigo;
                                ListaCodigos.Add(CampoCodigo);
                                continue;
                            }
                        }
                    }
                    insertarCodigosDeBarraAWord(doc);
                    if (File.Exists(@rutasEnModAdmin.RutaDeTemp + "/" + ContadorEtiquetas + "_0.pdf"))
                        File.Delete((@rutasEnModAdmin.RutaDeTemp + "/" + ContadorEtiquetas + "_0.pdf"));
                    doc.ExportAsFixedFormat(@rutasEnModAdmin.RutaDeTemp + "/" + ContadorEtiquetas + "_0.pdf", Word.WdExportFormat.wdExportFormatPDF,
                    OptimizeFor: Word.WdExportOptimizeFor.wdExportOptimizeForPrint,
                    BitmapMissingFonts: true, DocStructureTags: false);
                    doc.SaveAs2(@rutasEnModAdmin.RutaDeTemp + "/docTemp.docx");
                    doc.Saved = true;
                    ((Microsoft.Office.Interop.Word._Document)doc).Close();
                    ((Microsoft.Office.Interop.Word._Application)appWord).Quit();
                    File.Delete(@rutasEnModAdmin.RutaDeTemp + "/docTemp.docx");
                    File.Delete(@rutasEnModAdmin.RutaDeTemp + "/Etq_" + TipyVarEtqs.Key.ToString() + "_" + TipyVarEtqs.Value.ToString() + ".docx");
                    ContadorEtiquetas++;
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.matarProcesosWordExcel();
            }
        }
开发者ID:GeMaths,项目名称:etiquetasPMM,代码行数:101,代码来源:EtiquetasPallet.cs

示例5: GetReport

        public string GetReport()
        {
            try
            {
                _wordApp = new Word.Application();
                _doc = _wordApp.Documents.Add(_wordPath);
                _doc.Bookmarks["ДатаЗачисления"].Range.Text = EnrollmentDate.ToShortDateString();
                _doc.Bookmarks["ДатаЗачисления2"].Range.Text = EnrollmentDate.ToShortDateString();
                _doc.Bookmarks["ДатаРождения"].Range.Text = BirthDay.ToShortDateString();
                _doc.Bookmarks["ИдентификационныйНомер"].Range.Text = PassportNumberId;
                _doc.Bookmarks["КатегорияТС"].Range.Text = Program;
                _doc.Bookmarks["МестоРождения"].Range.Text = BirthPlace;
                _doc.Bookmarks["НачалоОбучения"].Range.Text = StartDate.ToShortDateString();
                _doc.Bookmarks["НомерДоговора"].Range.Text = ContractNumber.ToString();
                _doc.Bookmarks["ПаспортДатаВыдачи"].Range.Text = PassportIssueDate.ToShortDateString();
                _doc.Bookmarks["ПаспортКемВыдан"].Range.Text = PassportIssueBy;
                _doc.Bookmarks["ПаспортСерияНомер"].Range.Text = PassportNumber;
                _doc.Bookmarks["ПостояннаяРегистрация"].Range.Text = Registration;
                _doc.Bookmarks["ПрактикаЧасов"].Range.Text = PracticeHours.ToString();
                _doc.Bookmarks["ПрограммаОбучения"].Range.Text = Program;
                _doc.Bookmarks["Продолжительность"].Range.Text = (PracticeHours + TheoryHours).ToString();
                _doc.Bookmarks["СтоимостьОбучения"].Range.Text = Cost.ToString();
                _doc.Bookmarks["ТелефонСот"].Range.Text = PhoneMobile;
                _doc.Bookmarks["ТеорияЧасов"].Range.Text = TheoryHours.ToString();
                _doc.Bookmarks["ТипГруппы"].Range.Text = GroupType;
                _doc.Bookmarks["ФИОкурсанта"].Range.Text = LastName + " " + Name + " " + MiddleName;
                _doc.Bookmarks["ФИОкурсанта2"].Range.Text = LastName + " " + Name + " " + MiddleName;

                _doc.SaveAs2(FileName: _saveAsPath, FileFormat: Word.WdSaveFormat.wdFormatPDF);

            }
            catch (Exception)
            {
            }
            finally
            {
                _doc.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
                _wordApp.Quit(Word.WdSaveOptions.wdDoNotSaveChanges);
            }
            return _saveAsPath;
        }
开发者ID:IvanNkl,项目名称:AutoSchool,代码行数:41,代码来源:ContractReport.cs

示例6: GetReport

        public string GetReport()
        {
            try
            {
                _wordApp = new Word.Application();
                _doc = _wordApp.Documents.Add(_templateWordPath);

                _doc.Bookmarks["Город"].Range.Text = City;
                _doc.Bookmarks["Дата"].Range.Text = Date.ToShortDateString();
                _doc.Bookmarks["Заказчик"].Range.Text = Customer;
                _doc.Bookmarks["ЗаказчикПодпись"].Range.Text = CustomerInitials;
                _doc.Bookmarks["Исполнитель"].Range.Text = Executor;
                _doc.Bookmarks["ИсполнительПодпись"].Range.Text = ExecutorInitials;
                _doc.Bookmarks["НаименованиеПредприятия"].Range.Text = Organization;
                _doc.Bookmarks["СрокиПорядки"].Range.Text = TimeAndOrders;
                _doc.Bookmarks["СрокНачало"].Range.Text = StartDate.ToShortDateString();
                _doc.Bookmarks["СрокОкончание"].Range.Text = EndDate.ToShortDateString();
                _doc.Bookmarks["Стоимость"].Range.Text = Cost.ToString("C0", new System.Globalization.CultureInfo("be-BY"));
                _doc.Bookmarks["Услуги"].Range.Text = Service;

                _doc.SaveAs2(FileName: _documnetSavePath, FileFormat: Word.WdSaveFormat.wdFormatPDF);

                return _documnetSavePath;
            }
            catch (Exception)
            {
            }
            finally
            {
                _doc.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
                _wordApp.Quit(Word.WdSaveOptions.wdDoNotSaveChanges);
            }
            return null;
        }
开发者ID:IvanNkl,项目名称:PMKSite,代码行数:34,代码来源:ContractServiceReport.cs

示例7: GetReport

        public string GetReport()
        {
            try
            {
                _wordApp = new Word.Application();
                _doc = _wordApp.Documents.Add(_templateWordPath);

                _doc.Bookmarks["АрендаВЧас"].Range.Text = CostInHour.ToString("C0", new System.Globalization.CultureInfo("be-BY"));
                _doc.Bookmarks["Часов"].Range.Text = CountHours.ToString();
                _doc.Bookmarks["Арендатор"].Range.Text = Renter;
                _doc.Bookmarks["АрендаторПаспорт"].Range.Text = RenterPassport;
                _doc.Bookmarks["АрендаторТелефон"].Range.Text = RenterPhone;
                _doc.Bookmarks["АрендаторФИО"].Range.Text = RenterFIO;
                _doc.Bookmarks["Арендодатель"].Range.Text = LandLord;
                _doc.Bookmarks["АрендодательАдрес"].Range.Text = LandLordAddress;
                _doc.Bookmarks["АрендодательБанковскиеРеквизиты"].Range.Text = LandLordBank;
                _doc.Bookmarks["АрендодательЛицо"].Range.Text = LandLordFIO;
                _doc.Bookmarks["АрендодательНаименование"].Range.Text = LandLord;
                _doc.Bookmarks["АрендодательТелефон"].Range.Text = LandLordPhone;
                _doc.Bookmarks["Город"].Range.Text = City;
                _doc.Bookmarks["ГосНомер"].Range.Text = TransportRegNumber;
                _doc.Bookmarks["Дата"].Range.Text = Date.ToShortDateString();
                _doc.Bookmarks["ДатаНачалаДоговора"].Range.Text = ContractStartDate.ToShortDateString();
                _doc.Bookmarks["ДатаНеПозднее"].Range.Text = DateBeforeEnd.ToShortDateString();
                _doc.Bookmarks["ДатаОкончанияДоговора"].Range.Text = ContractEndDate.ToShortDateString();
                _doc.Bookmarks["НазваниеТС"].Range.Text = TransportName;
                _doc.Bookmarks["НазваниеТСКоммЭкс"].Range.Text = TransportName;
                _doc.Bookmarks["НазваниеТССубаренда"].Range.Text = TransportName;
                _doc.Bookmarks["Номер"].Range.Text = ContractNumber.ToString();
                _doc.Bookmarks["НомерКузова"].Range.Text = TransportEngineNumber;
                _doc.Bookmarks["НомерДвигателя"].Range.Text = TransportBodyNumber;
                _doc.Bookmarks["Пеня"].Range.Text = Fine.ToString();
                _doc.Bookmarks["СколькоЧеловек"].Range.Text = CrewCount.ToString();
                _doc.Bookmarks["СтоимостьАренды"].Range.Text = RentCost.ToString("C0", new System.Globalization.CultureInfo("be-BY"));
                _doc.Bookmarks["ТранспортноеСредство"].Range.Text = TransportName;
                _doc.Bookmarks["ЦелевоеНазначение"].Range.Text = TransportSpecialPurpose;

                _doc.SaveAs2(FileName: _documnetSavePath, FileFormat: Word.WdSaveFormat.wdFormatPDF);

                return _documnetSavePath;
            }
            catch (Exception)
            {
            }
            finally
            {
                _doc.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
                _wordApp.Quit(Word.WdSaveOptions.wdDoNotSaveChanges);
            }
            return null;
        }
开发者ID:IvanNkl,项目名称:PMKSite,代码行数:51,代码来源:ContractRentReport.cs

示例8: SaveCompare

        public static bool SaveCompare(bool ForceSave, bool SaveDoc)
        {
            try
            {
                //  int seq = 1;
                string strFileAttached = _fileName;
                if (strFileAttached != null)
                {
                    //Save the Contract
                    Globals.ThisAddIn.RemoveSaveHandler(); // remove the save handler to stop the save calling the save etc.

                    // if this is the first save - then save everything
                    if (_firstsave) ForceSave = true;

                    Globals.ThisAddIn.ProcessingStart("Save Contract");
                    DataReturn dr;
                    _doc = Globals.ThisAddIn.Application.ActiveDocument;

                    /*
                    Globals.ThisAddIn.ProcessingUpdate("Get the Clause Values");
                    foreach (Word.ContentControl cc in _doc.Range().ContentControls)
                    {
                        if (cc.Tag != null)
                        {
                            string tag = cc.Tag;
                            string docclausename = cc.Title;
                            Globals.ThisAddIn.ProcessingUpdate("Save " + docclausename);

                            string text = cc.Range.Text;
                            string[] taga = cc.Tag.Split('|');
                            if (taga[0] == "Concept")
                            {
                                dr = AxiomIRISRibbon.Utility.HandleData(_d.SaveDocumentClause("", _versionid, taga[1], taga[2], docclausename, seq++, text, false));
                            }
                            else if (taga[0] == "element")
                            {

                                dr = AxiomIRISRibbon.Utility.HandleData(_d.SaveDocumentClauseElement("",docclausename ,taga[2],"",_templateid,text,text ));

                            }
                        }
                    }

                    */

                    /*   List<string> clauseArray = new List<string>();
                       DataReturn ribbonClauseDr = _d.getRibbonClause(_templateid);
                       //check condition
                       DataTable ribbonClauseDt = ribbonClauseDr.dt;
                       foreach (Word.ContentControl cc in _doc.Range().ContentControls)
                       {
                           //
                           if (cc.Tag != null)
                           {
                               //
                               string tag = cc.Tag;
                               string docclausename = cc.Title;
                           }
                           string text = cc.Range.Text;
                           string[] taga = cc.Tag.Split('|');
                           if (taga[0] == "Concept")
                           {
                               //
                               if (!clauseArray.Contains(taga[2]))
                               {
                                   //
                                   clauseArray.Add(taga[2]);
                               }
                               //dr = _d.SaveRibbonClause(ribbonClauseDt, taga[1], taga[2], _templateid);
                           }
                       }
                       if (clauseArray.Count > 0)
                       {
                           dr = _d.SaveRibbonClause(ribbonClauseDt, clauseArray, _templateid);
                       }

                       */

                    dr = AxiomIRISRibbon.Utility.HandleData(_d.SaveVersion(_versionid, _matterid, _templateid, _versionName, _versionNumber));
                    if (!dr.success) return false;
                    _versionid = dr.id;

                    if (SaveDoc)
                    {
                        //Save the file as an attachment
                        //save this to a scratch file
                        Globals.ThisAddIn.ProcessingUpdate("Save Scratch");
                        _doc.SaveAs2(FileName: strFileAttached, FileFormat: Word.WdSaveFormat.wdFormatXMLDocument, CompatibilityMode: Word.WdCompatibilityMode.wdCurrent);

                        //Save a copy because document open in split view cannot be locked for upload
                        //into IRIS
                        Globals.ThisAddIn.ProcessingUpdate("Save Copy");
                        string filenamecopy = AxiomIRISRibbon.Utility.SaveTempFile(_versionid + "X");
                        System.IO.File.Copy(strFileAttached, filenamecopy); // Create a copy

                        // Now save the copied file - change this to always save as the version name
                        Globals.ThisAddIn.ProcessingUpdate("Save To SalesForce");
                        string vfilename = _versionName.Replace(" ", "_") + ".docx";
                        dr = AxiomIRISRibbon.Utility.HandleData(_d.UpdateFile(_attachmentid, vfilename, filenamecopy));
                    }
//.........这里部分代码省略.........
开发者ID:santoshsaha,项目名称:AxiomCS-Ribbon,代码行数:101,代码来源:CompareSideBar.xaml.cs

示例9: CreateWordsDocumentToOne


//.........这里部分代码省略.........
                       aDoc.Activate();

                       Console.WriteLine("megnyitva");

                       //Find and replace:
                       FindAndReplace(wordApp, "{NrMatricol}", candidat["NrMatricol"]);
                       FindAndReplace(wordApp, "{Nume}", candidat["Nume"]);
                       FindAndReplace(wordApp, "{Prenume}", candidat["Prenume"]);
                       FindAndReplace(wordApp, "{Tata}", candidat["Tata"]);
                       FindAndReplace(wordApp, "{Mama}", candidat["Mama"]);
                       FindAndReplace(wordApp, "{CNP>", candidat["CNP"]);
                       FindAndReplace(wordApp, "{DataNasterii}", candidat["DataNasterii"]);
                       FindAndReplace(wordApp, "{LoculNasterii}", candidat["LoculNasterii"]);
                       FindAndReplace(wordApp, "{Strada}", candidat["Strada"]);
                       FindAndReplace(wordApp, "{Nr}", candidat["Nr"]);
                       FindAndReplace(wordApp, "{Bloc}", candidat["Bloc"]);
                       FindAndReplace(wordApp, "{Scara}", candidat["Scara"]);
                       FindAndReplace(wordApp, "{Ap}", candidat["Ap"]);
                       FindAndReplace(wordApp, "{Localitate}", candidat["Localitate"]);
                       FindAndReplace(wordApp, "{Judet}", candidat["Judet"]);
                       FindAndReplace(wordApp, "{Cp}", candidat["Cp"]);
                       FindAndReplace(wordApp, "{Telefon}", candidat["Telefon"]);
                       FindAndReplace(wordApp, "{Studii}", candidat["Studii"]);
                       FindAndReplace(wordApp, "{Profesia}", candidat["Profesia"]);
                       FindAndReplace(wordApp, "{LocMunca}", candidat["LocMunca"]);
                       FindAndReplace(wordApp, "{Presedinte}", presedinte);
                       FindAndReplace(wordApp, "{Membru1}", membru1);
                       FindAndReplace(wordApp, "{Membru2}", membru2);

                       Console.WriteLine("cserelgetes");

                       object saveFullPath = savePath;

                       aDoc.SaveAs2(ref saveFullPath, ref missing, ref missing, ref missing,
                       ref missing, ref missing, ref missing,
                       ref missing, ref missing, ref missing,
                       ref missing, ref missing, ref missing,
                       ref missing, ref missing, ref missing);

                       //Close Document:

                       aDoc.Close(ref missing, ref missing, ref missing);
                       wordApp.Quit(false);

                       Marshal.FinalReleaseComObject(wordApp);
                       string PathToMerge = savePath + ".docx";
                       if (File.Exists(PathToMerge))
                       {
                           wordAppForOutput.Selection.InsertFile(PathToMerge, ref missing, true, ref missing, ref missing);
                           wordAppForOutput.Selection.InsertBreak(ref pageBreak);
                           File.Delete(PathToMerge);
                       }
                       else
                       {
                           Console.WriteLine("dosent exist the file");
                       }

                       aDoc = null;
                       wordApp = null;
                       List<int> processesaftergen = getRunningProcesses();
                       Console.WriteLine("COUNT > " + processesbeforegen.Count + "  " + processesaftergen.Count);
                       killProcesses(processesbeforegen, processesaftergen);
                   }
                   else
                   {
                       System.Windows.MessageBox.Show("file dose not exist.");
开发者ID:koppandiatt,项目名称:faszomxitprojekt,代码行数:67,代码来源:Report.cs

示例10: SaveAmend

        // Save Amend Document
        public static bool SaveAmend(bool ForceSave, bool SaveDoc, bool IsTemplate)
        {
            try
            {
                //System.Windows.Forms.MessageBox.Show("SaveAmend ");
                string strFileToSave, strVfilename, strAttachmentId;

                Globals.ThisAddIn.RemoveSaveHandler(); // remove the save handler to stop the save calling the save etc.

                //Globals.ThisAddIn.ProcessingStart("Save Contract");
                DataReturn dr;

                if (!IsTemplate)
                {
                    strFileToSave = _strAmendmentDocumentPath;
                    if (_versionName != null)
                    {
                        strVfilename = _versionName.Replace(" ", "_") + ".docx";
                    }
                    else { strVfilename = _strAmendmentDocumentName; }

                    strAttachmentId = _strNewAttachmentId;

                    // Globals.ThisAddIn.AddDocId(objtempDocAmendment, "Contract", "");
                }
                else
                {
                    strFileToSave = _strAmendmentTemplatePath;
                    if (_versionName != null)
                    {
                        strVfilename = _versionName.Replace(" ", "_") + "_Amendment.docx";
                    }
                    else
                    {

                        strVfilename = _strAmendmentTemplateName;
                    }
                    strAttachmentId = _strAmendmentAttachmentId;

                    //   Globals.ThisAddIn.AddDocId(objtempAmendmentTemplate, "Contract", "");
                }

                if (SaveDoc)
                {
                    _doc = Globals.ThisAddIn.Application.Documents[strVfilename];
                    //save this to a scratch file
                    //Globals.ThisAddIn.ProcessingUpdate("Save Scratch");
                    _doc.SaveAs2(FileName: strFileToSave, FileFormat: Word.WdSaveFormat.wdFormatXMLDocument, CompatibilityMode: Word.WdCompatibilityMode.wdCurrent);
                    //System.Windows.Forms.MessageBox.Show(" _doc.SaveAs2 ");

                    //Save a copy!
                    Globals.ThisAddIn.ProcessingUpdate("Save Copy");
                    string filenamecopy = AxiomIRISRibbon.Utility.SaveTempFile(_versionid + "Y");
                    Word.Document dcopy = Globals.ThisAddIn.Application.Documents.Add(strFileToSave, Visible: false);
                    dcopy.SaveAs2(FileName: filenamecopy, FileFormat: Word.WdSaveFormat.wdFormatXMLDocument, CompatibilityMode: Word.WdCompatibilityMode.wdCurrent);
                    //System.Windows.Forms.MessageBox.Show(" dcopy.SaveAs2 ");
                    var docclose = (Word._Document)dcopy;
                    docclose.Close();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(docclose);

                    Globals.ThisAddIn.ProcessingUpdate("Save To SalesForce");

                    dr = AxiomIRISRibbon.Utility.HandleData(_d.UpdateFile(strAttachmentId, strVfilename, filenamecopy));
                }
                Globals.ThisAddIn.AddSaveHandler(); // add it back in
                Globals.ThisAddIn.ProcessingStop("End");
                //System.Windows.Forms.MessageBox.Show("After End ");
                return true;
            }
            catch (Exception ex)
            {
                //System.Windows.Forms.MessageBox.Show("After End ");
                return true;
            }
        }
开发者ID:santoshsaha,项目名称:AxiomCS-Ribbon,代码行数:76,代码来源:CompareAmendment.xaml.cs

示例11: SaveContract

        public bool SaveContract(bool ForceSave, bool SaveDoc)
        {
            string strFileAttached = _fileName;
            //Save the Contract
            Globals.ThisAddIn.RemoveSaveHandler(); // remove the save handler to stop the save calling the save etc.

            Globals.ThisAddIn.ProcessingStart("Save Contract");
            DataReturn dr;
              _doc = Globals.ThisAddIn.Application.ActiveDocument;

            dr = AxiomIRISRibbon.Utility.HandleData(_d.SaveVersion(_versionid, _matterid, _templateid, _versionName, _versionNumber));
            if (!dr.success) return false;
            _versionid = dr.id;

            if (SaveDoc)
            {

                //Save the file as an attachment
                //save this to a scratch file
                Globals.ThisAddIn.ProcessingUpdate("Save Scratch");
             //   string filename = AxiomIRISRibbon.Utility.SaveTempFile(_versionid);
                _doc.SaveAs2(FileName: strFileAttached, FileFormat: Word.WdSaveFormat.wdFormatXMLDocument, CompatibilityMode: Word.WdCompatibilityMode.wdCurrent);

                //Save a copy!
                Globals.ThisAddIn.ProcessingUpdate("Save Copy");
                string filenamecopy =  AxiomIRISRibbon.Utility.SaveTempFile(_versionid + "X");
                Word.Document dcopy = Globals.ThisAddIn.Application.Documents.Add(strFileAttached, Visible: false);
                dcopy.SaveAs2(FileName: filenamecopy, FileFormat: Word.WdSaveFormat.wdFormatXMLDocument, CompatibilityMode: Word.WdCompatibilityMode.wdCurrent);

                var docclose = (Microsoft.Office.Interop.Word._Document)dcopy;
                docclose.Close();
                System.Runtime.InteropServices.Marshal.ReleaseComObject(docclose);

                //Now save the file - change this to always save as the version name

                Globals.ThisAddIn.ProcessingUpdate("Save To SalesForce");
                string vfilename = _versionName.Replace(" ", "_") + ".docx";
                dr = AxiomIRISRibbon.Utility.HandleData(_d.UpdateFile(_attachmentid, vfilename, filenamecopy));

            }
            Globals.ThisAddIn.AddSaveHandler(); // add it back in
            Globals.ThisAddIn.ProcessingStop("End");
            return true;
        }
开发者ID:santoshsaha,项目名称:AxiomCS-Ribbon01,代码行数:44,代码来源:CompareSideBar.xaml.cs

示例12: SaveCombinedDoc

        public DataReturn SaveCombinedDoc(string newAttachmentId, string fileAmendmentTemplatePath)
        {
            DataReturn dr = new DataReturn();
            try
            {
                string strFileAttached = fileAmendmentTemplatePath;
                //Save the Contract

                //  DataReturn dr;
                _doc = Globals.ThisAddIn.Application.ActiveDocument;

                //Remove the contract refrence and id from document before save as combined doc.
                //To avoid save as a template
                Globals.ThisAddIn.AddDocId(_doc, "", "", "");
                //End

                _doc.SaveAs2(FileName: strFileAttached, FileFormat: Word.WdSaveFormat.wdFormatXMLDocument, CompatibilityMode: Word.WdCompatibilityMode.wdCurrent);
                string filenamecopy = AxiomIRISRibbon.Utility.SaveTempFile(_versionid + "Z");
                Word.Document dcopy = Globals.ThisAddIn.Application.Documents.Add(strFileAttached, Visible: false);
                dcopy.SaveAs2(FileName: filenamecopy, FileFormat: Word.WdSaveFormat.wdFormatXMLDocument, CompatibilityMode: Word.WdCompatibilityMode.wdCurrent);

                var docclose = (Word._Document)dcopy;
                docclose.Close();
                System.Runtime.InteropServices.Marshal.ReleaseComObject(docclose);

                string vfilename = _versionName.Replace(" ", "_") + ".docx";
                dr = AxiomIRISRibbon.Utility.HandleData(_d.UpdateFile(newAttachmentId, vfilename, filenamecopy));

                return dr;
            }
            catch (Exception ex)
            {
                return dr;
            }
        }
开发者ID:santoshsaha,项目名称:AxiomCS-Ribbon,代码行数:35,代码来源:CompareAmendment.xaml.cs

示例13: GetReport

        public string GetReport()
        {
            try
            {
                _wordApp = new Word.Application();
                _doc = _wordApp.Documents.Add(_templateWordPath);

                _doc.Bookmarks["Город"].Range.Text = City;
                _doc.Bookmarks["Дата"].Range.Text = Date.ToShortDateString();
                _doc.Bookmarks["ДатаДоговора"].Range.Text = ContractDate.ToShortDateString();
                _doc.Bookmarks["ДатаДоговора2"].Range.Text = ContractDate.ToShortDateString();
                _doc.Bookmarks["ДатаДоговора3"].Range.Text = ContractDate.ToShortDateString();
                _doc.Bookmarks["ДатаОкончания"].Range.Text = EndDate.ToShortDateString();
                _doc.Bookmarks["Директор"].Range.Text = Director;
                _doc.Bookmarks["Заказчик"].Range.Text = Customer;
                _doc.Bookmarks["ЗаказчикФИО"].Range.Text = CustomerFIO;
                _doc.Bookmarks["НомерДоговора"].Range.Text = ContractNumber.ToString();
                _doc.Bookmarks["НомерДоговора2"].Range.Text = ContractNumber.ToString();
                _doc.Bookmarks["НомерДоговора3"].Range.Text = ContractNumber.ToString();
                _doc.Bookmarks["ПаспортВыдан"].Range.Text = string.Format("{0} {1} г.", PassportIssuedBy, PassportIssuedDate.ToShortDateString());
                _doc.Bookmarks["ПаспортНомер"].Range.Text = PassportNumber;
                _doc.Bookmarks["ПаспортСерия"].Range.Text = PassportSeries;
                _doc.Bookmarks["Подрядчик"].Range.Text = Contractor;
                _doc.Bookmarks["ПодрядчикФИО"].Range.Text = ContractorFIO;
                _doc.Bookmarks["Работы"].Range.Text = Services;
                _doc.Bookmarks["ФактическаяДатаОкончания"].Range.Text = ActualEndDate.ToShortDateString();

                _doc.SaveAs2(FileName: _documnetSavePath, FileFormat: Word.WdSaveFormat.wdFormatPDF);

                return _documnetSavePath;
            }
            catch (Exception)
            {
            }
            finally
            {
                _doc.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
                _wordApp.Quit(Word.WdSaveOptions.wdDoNotSaveChanges);
            }
            return null;
        }
开发者ID:IvanNkl,项目名称:PMKSite,代码行数:41,代码来源:ActServiceReport.cs

示例14: GetReport

 public string GetReport()
 {
     try
     {
         _wordApp = new Word.Application();
         _doc = _wordApp.Documents.Add(_wordPath);
         _doc.Bookmarks["ГодРождения"].Range.Text = BirthDay.Year.ToString().Trim();
         _doc.Bookmarks["Гражданство"].Range.Text = Nationality;
         _doc.Bookmarks["ДатаЗачисления"].Range.Text = EnrollmentDate.ToShortDateString();
         _doc.Bookmarks["ДатаМесяцРождения"].Range.Text = BirthDay.Day + " " + GetMonthName(BirthDay.Month);
         _doc.Bookmarks["Должность"].Range.Text = JobPosition;
         _doc.Bookmarks["МедСправка"].Range.Text = "№" + MedicalNumber + " от " + MedicalDate.ToShortDateString() + ", " + MedicalName;
         _doc.Bookmarks["МестоРаботы"].Range.Text = Job;
         _doc.Bookmarks["МестоРождения"].Range.Text = BirthPlace;
         _doc.Bookmarks["Образование"].Range.Text = Education;
         _doc.Bookmarks["ОтФИО"].Range.Text = FIO;
         _doc.Bookmarks["ПаспортВыдан"].Range.Text = PassportIssueBy + " " + PassportIssueDate.ToShortDateString();
         _doc.Bookmarks["ПаспортСерия1"].Range.Text = PassportNumber.Substring(0, 2);
         _doc.Bookmarks["ПаспортСерия2"].Range.Text = PassportNumber.Substring(3, PassportNumber.Length - 3);
         _doc.Bookmarks["Программа"].Range.Text = Program;
         _doc.Bookmarks["Регистрация"].Range.Text = Registration;
         _doc.Bookmarks["ТелДом"].Range.Text = PhoneHome;
         _doc.Bookmarks["ТелМоб"].Range.Text = PhoneMobile;
         _doc.Bookmarks["ФИО"].Range.Text = LastName + " " + Name + " " + MiddleName;
         _doc.SaveAs2(FileName: _saveAsPath, FileFormat: Word.WdSaveFormat.wdFormatPDF);
     }
     catch (Exception)
     {
     }
     finally
     {
         _doc.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
         _wordApp.Quit(Word.WdSaveOptions.wdDoNotSaveChanges);
     }
     return _saveAsPath;
 }
开发者ID:IvanNkl,项目名称:AutoSchool,代码行数:36,代码来源:StatementReport.cs

示例15: GetReport

        public string GetReport()
        {
            try
            {
                _wordApp = new Word.Application();
                _doc = _wordApp.Documents.Add(_templateWordPath);

                _doc.Bookmarks["Арендатор"].Range.Text = Renter;
                _doc.Bookmarks["АрендаторФИО"].Range.Text = RenterFIO;
                _doc.Bookmarks["Арендодатель"].Range.Text = LandLord;
                _doc.Bookmarks["АрендодательФИО"].Range.Text = Director;
                _doc.Bookmarks["Город"].Range.Text = City;
                _doc.Bookmarks["ГосНомер1"].Range.Text = TransportRegNumber;
                _doc.Bookmarks["ГосНомер2"].Range.Text = TransportRegNumber;
                _doc.Bookmarks["Дата"].Range.Text = Date.ToShortDateString();
                _doc.Bookmarks["ДатаДоговора"].Range.Text = ContractDate.ToShortDateString();
                _doc.Bookmarks["Директор"].Range.Text = LandLordFIO;
                _doc.Bookmarks["Номер"].Range.Text = Number.ToString();
                _doc.Bookmarks["Транспорт1"].Range.Text = TransportName;
                _doc.Bookmarks["Транспорт2"].Range.Text = TransportName;

                _doc.SaveAs2(FileName: _documnetSavePath, FileFormat: Word.WdSaveFormat.wdFormatPDF);

                return _documnetSavePath;
            }
            catch (Exception)
            {
            }
            finally
            {
                _doc.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
                _wordApp.Quit(Word.WdSaveOptions.wdDoNotSaveChanges);
            }
            return null;
        }
开发者ID:IvanNkl,项目名称:PMKSite,代码行数:35,代码来源:ActRentReport.cs


注:本文中的Microsoft.Office.Interop.Word.Document.SaveAs2方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。