public void ReplaceDefaultText(TempDocsDetailCollection content) { try { int count = 0; Microsoft.Office.Interop.Word.Shapes tx = PareGooWord.Globals.ThisAddIn.Application.ActiveDocument.Shapes; for (int i = 0; i < tx.Count; i++) { try { if (tx[i].Type == Microsoft.Office.Core.MsoShapeType.msoTextBox) { foreach (TempDocsDetail item in content) { if (item.tpControlKey == tx[i].Name) { tx[i].TextFrame.TextRange.Text = "\n" + item.tpkeyContent; break; } } } } catch (Exception ex) { } } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("خطا در آفیس:" + "\r\n" + ex.Message); } }
private static void saveFileToParegooDB() { try { PareGooWord.Globals.ThisAddIn.Application.ActiveDocument.Save(); Microsoft.Office.Interop.Word.Shapes tx = PareGooWord.Globals.ThisAddIn.Application.ActiveDocument.Shapes; for (int i = 0; i < tx.Count; i++) { try { if (tx[i].Type == Microsoft.Office.Core.MsoShapeType.msoTextBox) { if (tx[i].TextFrame.TextRange.Text != "\r" && tx[i].TextFrame.TextRange.Text != " \r") { content += tx[i].TextFrame.TextRange.Text.Trim() + " "; } } } catch (Exception ex) { } } if (tableName == "tempdocs" && fileID != string.Empty) { TempDocManager.EditFile(fileID, filePath, content, conString); } else if (tableName == "filedocs" && fileID != string.Empty) { FileDocManager.EditFile(fileID, filePath, content, conString); } else if (tableName == "deskdocs" && fileID != string.Empty) { Lawyer.Common.VB.Timing.TimingManager.EditTimeDocs(filePath, fileName, conString); } if (tableName != string.Empty && fileID != string.Empty) { System.Windows.Forms.MessageBox.Show("فایل ذخیره شد"); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("خطا در آفیس:" + "\r\n" + ex.Message); } }
private void btnPrintOnLetter_Click(object sender, RibbonControlEventArgs e) { //if(!PareGooWord.Globals.ThisAddIn.Application.ActiveDocument.ProtectionType== Microsoft.Office.Interop.Word.WdProtectionType.wdNoProtection) // PareGooWord.Globals.ThisAddIn.Application.ActiveDocument.Protect() int Undo_NO = 0; Microsoft.Office.Interop.Word.Shapes tx = PareGooWord.Globals.ThisAddIn.Application.ActiveDocument.Shapes; for (int i = 0; i < tx.Count; i++) { try { if (tx[i].Type == Microsoft.Office.Core.MsoShapeType.msoPicture) { tx[i].Visible = Microsoft.Office.Core.MsoTriState.msoFalse; Undo_NO += 1; } } catch (Exception ex) { } } Microsoft.Office.Interop.Word.Tables tb = PareGooWord.Globals.ThisAddIn.Application.ActiveDocument.Tables; for (int i = 0; i < tb.Count; i++) { try { tb[i].Borders.InsideColor = Microsoft.Office.Interop.Word.WdColor.wdColorWhite; tb[i].Borders.OutsideColor = Microsoft.Office.Interop.Word.WdColor.wdColorWhite; Undo_NO += 2; } catch (Exception ex) { } } showPrintDialog(); for (int i = 0; i < Undo_NO; i++) { PareGooWord.Globals.ThisAddIn.Application.ActiveDocument.Undo(); } }