//打开word public void OpenWord(WinWordControl.WinWordControl winWordControl1, string wordUrl) { if (string.IsNullOrEmpty(wordUrl)) { wordUrl = GetPath() + @"\Template\国废验收报告-标准模版.doc"; } //else //{ // wordUrl = GetPath() + wordUrl; //} try { winWordControl1.CloseControl(); } catch { } finally { winWordControl1.document = null; WinWordControl.WinWordControl.wd = null; WinWordControl.WinWordControl.wordWnd = 0; } try { winWordControl1.LoadDocument(wordUrl); WordComent(winWordControl1.document); } catch (Exception ex) { String err = ex.Message; } }
/// <summary> /// 保存word /// </summary> /// <param name="winWordControl1">主控件</param> /// <param name="pFileName">文档名称</param> /// <returns></returns> public string SaveWord(WinWordControl.WinWordControl winWordControl1, string pFileName) { if (string.IsNullOrEmpty(pFileName)) { pFileName = DateTime.Now.ToString("yyMMddHHmmss"); } string path = @"\SystemWord\" + DateTime.Now.ToShortDateString() + "\\"; string savePath = path + pFileName + ".doc"; string dic = GetPath() + path; if (!System.IO.Directory.Exists(dic)) { System.IO.Directory.CreateDirectory(dic); } string wordUrl = dic + pFileName + ".doc"; object myNothing = System.Reflection.Missing.Value; object myFileName = wordUrl; object myWordFormatDocument = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatDocument; object myLockd = false; object myPassword = ""; object myAddto = true; try { ////winWordControl1.document.SaveAs(ref myFileName, ref myWordFormatDocument, ref myLockd, ref myPassword, ref myAddto, ref myPassword, //// ref myLockd, ref myLockd, ref myLockd, ref myNothing, ref myNothing); /* * this.winWordControl1.document.SaveAs(ref myFileName, ref myWordFormatDocument, ref myLockd, ref myPassword, ref myAddto, ref myPassword, * ref myLockd, ref myLockd, ref myLockd, ref myLockd, ref myNothing, ref myNothing, ref myNothing, * ref myNothing, ref myNothing, ref myNothing); */ } catch { throw new Exception("导出word文档失败!"); } return(savePath); }
/// <summary> /// /// </summary> private void InitializeComponent() { this.load = new System.Windows.Forms.Button(); this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.close = new System.Windows.Forms.Button(); this.btnNewForm = new System.Windows.Forms.Button(); this.winWordControl1 = new WinWordControl.WinWordControl(); this.SuspendLayout(); // // load // this.load.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.load.Location = new System.Drawing.Point(592, 24); this.load.Name = "load"; this.load.Size = new System.Drawing.Size(68, 32); this.load.TabIndex = 1; this.load.Text = "load"; this.load.Click += new System.EventHandler(this.load_Click); // // openFileDialog1 // this.openFileDialog1.Filter = "ms word 2003(*.doc)|*.doc|ms word 2007(*.docx)|*.docx"; this.openFileDialog1.Title = "Please selected upload file"; this.openFileDialog1.DefaultExt = "doc"; this.openFileDialog1.CheckFileExists = true; this.openFileDialog1.CheckPathExists = true; // // close // this.close.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.close.Location = new System.Drawing.Point(592, 66); this.close.Name = "close"; this.close.Size = new System.Drawing.Size(68, 32); this.close.TabIndex = 5; this.close.Text = "Close"; this.close.Click += new System.EventHandler(this.close_Click); // // btnNewForm // this.btnNewForm.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnNewForm.Location = new System.Drawing.Point(592, 111); this.btnNewForm.Name = "btnNewForm"; this.btnNewForm.Size = new System.Drawing.Size(68, 32); this.btnNewForm.TabIndex = 6; this.btnNewForm.Text = "New Form"; this.btnNewForm.Click += new System.EventHandler(this.btnNewForm_Click); // // winWordControl1 // this.winWordControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.winWordControl1.Location = new System.Drawing.Point(0, 0); this.winWordControl1.Name = "winWordControl1"; this.winWordControl1.Size = new System.Drawing.Size(586, 383); this.winWordControl1.TabIndex = 2; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(672, 389); this.Controls.Add(this.btnNewForm); this.Controls.Add(this.close); this.Controls.Add(this.winWordControl1); this.Controls.Add(this.load); this.Name = "Form1"; this.Text = "Form1"; this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.Activated += new System.EventHandler(this.OnActivate); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); this.Load += new System.EventHandler(this.Form1_Load); this.ResumeLayout(false); }
public WordPringOut(string qcinf, WinWordControl.WinWordControl winWordControl) { Common.intQCInfo_ID = int.Parse(qcinf); winWordControl1 = winWordControl; Login(); }
WinWordControl.WinWordControl winWordControl1;// = new WinWordControl.WinWordControl(); public WordPringOut(WinWordControl.WinWordControl winWordControl) { Login(); }
/// <summary> /// /// </summary> private void InitializeComponent() { this.load = new System.Windows.Forms.Button(); this.winWordControl1 = new WinWordControl.WinWordControl(); this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.button1 = new System.Windows.Forms.Button(); this.Restore = new System.Windows.Forms.Button(); this.close = new System.Windows.Forms.Button(); this.SuspendLayout(); // // load // this.load.Location = new System.Drawing.Point(592, 24); this.load.Name = "load"; this.load.Size = new System.Drawing.Size(56, 32); this.load.TabIndex = 1; this.load.Text = "load"; this.load.Click += new System.EventHandler(this.load_Click); // // winWordControl1 // this.winWordControl1.Dock = System.Windows.Forms.DockStyle.Left; this.winWordControl1.Name = "winWordControl1"; this.winWordControl1.Size = new System.Drawing.Size(560, 389); this.winWordControl1.TabIndex = 2; // // openFileDialog1 // this.openFileDialog1.Filter = "WordDateien (*.doc)|*.doc"; // // button1 // this.button1.Location = new System.Drawing.Point(592, 152); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(56, 32); this.button1.TabIndex = 3; this.button1.Text = "PreActivate"; this.button1.Click += new System.EventHandler(this.button1_Click); // // Restore // this.Restore.Location = new System.Drawing.Point(592, 208); this.Restore.Name = "Restore"; this.Restore.Size = new System.Drawing.Size(56, 32); this.Restore.TabIndex = 4; this.Restore.Text = "Restore Word"; this.Restore.Click += new System.EventHandler(this.Restore_Click); // // close // this.close.Location = new System.Drawing.Point(592, 72); this.close.Name = "close"; this.close.Size = new System.Drawing.Size(56, 32); this.close.TabIndex = 5; this.close.Text = "Close"; this.close.Click += new System.EventHandler(this.close_Click); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(672, 389); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.close, this.Restore, this.button1, this.winWordControl1, this.load }); this.Name = "Form1"; this.Text = "Form1"; this.Activated += new System.EventHandler(this.OnActivate); this.ResumeLayout(false); }