日韩精品免费一区二区三区_久久精品国产三级不卡_免费观看中文字幕_好男人社区神马在线观看www

注冊|登錄

聯(lián)系電話:024-31891684  13390130939
沈陽軟件公司--沈陽軟件定制

沈陽軟件開發(fā)_沈陽軟件公司_沈陽軟件定制/軟件/最新技術(shù)

Latest technology最新技術(shù)

[C#]通過調(diào)用Word模板(Doc、dot)直接打印

瀏覽量:4851

通過替換模板中的指定 書簽 來進(jìn)行內(nèi)容的替換、整合,然后直接發(fā)送到打印打印,也可以導(dǎo)出。即把打印出的語句換成保存函數(shù)。

public static class myPrintByOffice

{
public static void byDoc(String time,String uid )
{
Microsoft.Office.Interop.Word.Application app = null;
Microsoft.Office.Interop.Word.Document doc = null;
 
object missing = System.Reflection.Missing.Value;
object templateFile = @"D:\download\dot.doc";
try
{
app = new Microsoft.Office.Interop.Word.ApplicationClass();
doc = app.Documents.Add(ref templateFile, ref missing, ref missing, ref missing);
 
try
{
foreach (Microsoft.Office.Interop.Word.Bookmark bm in doc.Bookmarks)
{
bm.Select();
 
string item = bm.Name;
 
if (item.Equals("A"))
{
bm.Range.Text = time == null ? "" : time.ToString();
}
else if (item.Equals("B"))
{
bm.Range.Text = uid == null ? "" : uid.ToString();
}
}
}
catch
{
}
 
//打印
doc.PrintOut(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, ref missing, ref missing, ref missing);
}
catch (Exception exp)
{
throw new Exception(exp.Message);
//MessageBox.Show(exp.Message, this.Text);
}
 
//銷毀word進(jìn)程
finally
{
object saveChange = Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges;
if (doc != null)
doc.Close(ref saveChange, ref missing, ref missing);
 
if (app != null)
app.Quit(ref missing, ref missing, ref missing);
}
}

 

 


 

 

針對(duì)一些問內(nèi)容替換或其他操作word的問題,我整理了一個(gè)類,里面的方法應(yīng)該夠用的了,里面有文字的替換,圖片的插入等等。

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
 
namespace WordAddinSample
{
public class WordHelp
{
private Microsoft.Office.Interop.Word.ApplicationClass oWordApplic; // a reference to Word application
private Microsoft.Office.Interop.Word.Document oDoc; // a reference to the document
object missing = System.Reflection.Missing.Value;
 
public Microsoft.Office.Interop.Word.ApplicationClass WordApplication
{
get { return oWordApplic; }
}
 
public WordHelp()
{
// activate the interface with the COM object of Microsoft Word
oWordApplic = new Microsoft.Office.Interop.Word.ApplicationClass();
}
 
public WordHelp(Microsoft.Office.Interop.Word.ApplicationClass wordapp)
{
oWordApplic = wordapp;
}
 
#region 文件操作
 
// Open a file (the file must exists) and activate it
public void Open(string strFileName)
{
object fileName = strFileName;
object readOnly = false;
object isVisible = true;
 
oDoc = oWordApplic.Documents.Open(ref fileName, ref missing, ref readOnly,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);
 
oDoc.Activate();
}
 
// Open a new document
public void Open()
{
oDoc = oWordApplic.Documents.Add(ref missing, ref missing, ref missing, ref missing);
 
oDoc.Activate();
}
 
public void Quit()
{
oWordApplic.Application.Quit(ref missing, ref missing, ref missing);
}
 
/// <summary>
/// 附加dot模版文件
/// </summary>
private void LoadDotFile(string strDotFile)
{
if (!string.IsNullOrEmpty(strDotFile))
{
Microsoft.Office.Interop.Word.Document wDot = null;
if (oWordApplic != null)
{
oDoc = oWordApplic.ActiveDocument;
 
oWordApplic.Selection.WholeStory();
 
//string strContent = oWordApplic.Selection.Text;
 
oWordApplic.Selection.Copy();
wDot = CreateWordDocument(strDotFile, true);
 
object bkmC = "Content";
 
if (oWordApplic.ActiveDocument.Bookmarks.Exists("Content") == true)
{
oWordApplic.ActiveDocument.Bookmarks.get_Item
(ref bkmC).Select();
}
 
//對(duì)標(biāo)簽"Content"進(jìn)行填充
//直接寫入內(nèi)容不能識(shí)別表格什么的
//oWordApplic.Selection.TypeText(strContent);
oWordApplic.Selection.Paste();
oWordApplic.Selection.WholeStory();
oWordApplic.Selection.Copy();
wDot.Close(ref missing, ref missing, ref missing);
 
oDoc.Activate();
oWordApplic.Selection.Paste();
 
}
}
}
 
///
/// 打開Word文檔,并且返回對(duì)象oDoc
/// 完整Word文件路徑+名稱
/// 返回的Word.Document oDoc對(duì)象
public Microsoft.Office.Interop.Word.Document CreateWordDocument(string FileName, bool HideWin)
{
if (FileName == "") return null;
 
oWordApplic.Visible = HideWin;
oWordApplic.Caption = "";
oWordApplic.Options.CheckSpellingAsYouType = false;
oWordApplic.Options.CheckGrammarAsYouType = false;
 
Object filename = FileName;
Object ConfirmConversions = false;
Object ReadOnly = true;
Object AddToRecentFiles = false;
 
Object PasswordDocument = System.Type.Missing;
Object PasswordTemplate = System.Type.Missing;
Object Revert = System.Type.Missing;
Object WritePasswordDocument = System.Type.Missing;
Object WritePasswordTemplate = System.Type.Missing;
Object Format = System.Type.Missing;
Object Encoding = System.Type.Missing;
Object Visible = System.Type.Missing;
Object OpenAndRepair = System.Type.Missing;
Object DocumentDirection = System.Type.Missing;
Object NoEncodingDialog = System.Type.Missing;
Object XMLTransform = System.Type.Missing;
try
{
Microsoft.Office.Interop.Word.Document wordDoc = oWordApplic.Documents.Open(ref filename, ref ConfirmConversions,
ref ReadOnly, ref AddToRecentFiles, ref PasswordDocument, ref PasswordTemplate,
ref Revert, ref WritePasswordDocument, ref WritePasswordTemplate, ref Format,
ref Encoding, ref Visible, ref OpenAndRepair, ref DocumentDirection,
ref NoEncodingDialog, ref XMLTransform);
return wordDoc;
 
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return null;
}
}
 
public void SaveAs(Microsoft.Office.Interop.Word.Document oDoc, string strFileName)
{
object fileName = strFileName;
if (File.Exists(strFileName))
{
if (MessageBox.Show("文件'" + strFileName + "'已經(jīng)存在,選確定覆蓋原文件,選取消退出操作!", "警告", MessageBoxButtons.OKCancel) == DialogResult.OK)
{
oDoc.SaveAs(ref fileName, 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);
}
else
{
Clipboard.Clear();
}
}
else
{
oDoc.SaveAs(ref fileName, 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);
}
}
 
public void SaveAsHtml(Microsoft.Office.Interop.Word.Document oDoc, string strFileName)
{
object fileName = strFileName;
 
//wdFormatWebArchive保存為單個(gè)網(wǎng)頁文件
//wdFormatFilteredHTML保存為過濾掉word標(biāo)簽的htm文件,缺點(diǎn)是有圖片的話會(huì)產(chǎn)生網(wǎng)頁文件夾
if (File.Exists(strFileName))
{
if (MessageBox.Show("文件'" + strFileName + "'已經(jīng)存在,選確定覆蓋原文件,選取消退出操作!", "警告", MessageBoxButtons.OKCancel) == DialogResult.OK)
{
object Format = (int)Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatWebArchive;
oDoc.SaveAs(ref fileName, ref Format, 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);
}
else
{
Clipboard.Clear();
}
}
else
{
object Format = (int)Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatWebArchive;
oDoc.SaveAs(ref fileName, ref Format, 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);
}
}
 
public void Save()
{
oDoc.Save();
}
 
public void SaveAs(string strFileName)
{
object fileName = strFileName;
 
oDoc.SaveAs(ref fileName, 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);
}
 
// Save the document in HTML format
public void SaveAsHtml(string strFileName)
{
object fileName = strFileName;
object Format = (int)Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML;
oDoc.SaveAs(ref fileName, ref Format, 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);
}
 
#endregion
 
#region 添加菜單(工具欄)項(xiàng)
 
////添加單獨(dú)的菜單項(xiàng)
//public void AddMenu(Microsoft.Office.Core.CommandBarPopup popuBar)
//{
// Microsoft.Office.Core.CommandBar menuBar = null;
// menuBar = this.oWordApplic.CommandBars["Menu Bar"];
// popuBar = (Microsoft.Office.Core.CommandBarPopup)this.oWordApplic.CommandBars.FindControl(Microsoft.Office.Core.MsoControlType.msoControlPopup, missing, popuBar.Tag, true);
// if (popuBar == null)
// {
// popuBar = (Microsoft.Office.Core.CommandBarPopup)menuBar.Controls.Add(Microsoft.Office.Core.MsoControlType.msoControlPopup, missing, missing, missing, missing);
// }
//}
 
////添加單獨(dú)工具欄
//public void AddToolItem(string strBarName, string strBtnName)
//{
// Microsoft.Office.Core.CommandBar toolBar = null;
// toolBar = (Microsoft.Office.Core.CommandBar)this.oWordApplic.CommandBars.FindControl(Microsoft.Office.Core.MsoControlType.msoControlButton, missing, strBarName, true);
// if (toolBar == null)
// {
// toolBar = (Microsoft.Office.Core.CommandBar)this.oWordApplic.CommandBars.Add(
// Microsoft.Office.Core.MsoControlType.msoControlButton,
// missing, missing, missing);
// toolBar.Name = strBtnName;
// toolBar.Visible = true;
// }
//}
 
#endregion
 
#region 移動(dòng)光標(biāo)位置
 
// Go to a predefined bookmark, if the bookmark doesn't exists the application will raise an error
public void GotoBookMark(string strBookMarkName)
{
// VB : Selection.GoTo What:=wdGoToBookmark, Name:="nome"
object Bookmark = (int)Microsoft.Office.Interop.Word.WdGoToItem.wdGoToBookmark;
object NameBookMark = strBookMarkName;
oWordApplic.Selection.GoTo(ref Bookmark, ref missing, ref missing, ref NameBookMark);
}
 
public void GoToTheEnd()
{
// VB : Selection.EndKey Unit:=wdStory
object unit;
unit = Microsoft.Office.Interop.Word.WdUnits.wdStory;
oWordApplic.Selection.EndKey(ref unit, ref missing);
}
 
public void GoToLineEnd()
{
object unit = Microsoft.Office.Interop.Word.WdUnits.wdLine;
object ext = Microsoft.Office.Interop.Word.WdMovementType.wdExtend;
oWordApplic.Selection.EndKey(ref unit, ref ext);
}
 
public void GoToTheBeginning()
{
// VB : Selection.HomeKey Unit:=wdStory
object unit;
unit = Microsoft.Office.Interop.Word.WdUnits.wdStory;
oWordApplic.Selection.HomeKey(ref unit, ref missing);
}
 
public void GoToTheTable(int ntable)
{
// Selection.GoTo What:=wdGoToTable, Which:=wdGoToFirst, Count:=1, Name:=""
// Selection.Find.ClearFormatting
// With Selection.Find
// .Text = ""
// .Replacement.Text = ""
// .Forward = True
// .Wrap = wdFindContinue
// .Format = False
// .MatchCase = False
// .MatchWholeWord = False
// .MatchWildcards = False
// .MatchSoundsLike = False
// .MatchAllWordForms = False
// End With
 
object what;
what = Microsoft.Office.Interop.Word.WdUnits.wdTable;
object which;
which = Microsoft.Office.Interop.Word.WdGoToDirection.wdGoToFirst;
object count;
count = 1;
oWordApplic.Selection.GoTo(ref what, ref which, ref count, ref missing);
oWordApplic.Selection.Find.ClearFormatting();
 
oWordApplic.Selection.Text = "";
}
 
public void GoToRightCell()
{
// Selection.MoveRight Unit:=wdCell
object direction;
direction = Microsoft.Office.Interop.Word.WdUnits.wdCell;
oWordApplic.Selection.MoveRight(ref direction, ref missing, ref missing);
}
 
public void GoToLeftCell()
{
// Selection.MoveRight Unit:=wdCell
object direction;
direction = Microsoft.Office.Interop.Word.WdUnits.wdCell;
oWordApplic.Selection.MoveLeft(ref direction, ref missing, ref missing);
}
 
public void GoToDownCell()
{
// Selection.MoveRight Unit:=wdCell
object direction;
direction = Microsoft.Office.Interop.Word.WdUnits.wdLine;
oWordApplic.Selection.MoveDown(ref direction, ref missing, ref missing);
}
 
public void GoToUpCell()
{
// Selection.MoveRight Unit:=wdCell
object direction;
direction = Microsoft.Office.Interop.Word.WdUnits.wdLine;
oWordApplic.Selection.MoveUp(ref direction, ref missing, ref missing);
}
 
#endregion
 
#region 插入操作
 
public void InsertText(string strText)
{
oWordApplic.Selection.TypeText(strText);
}
 
public void InsertLineBreak()
{
oWordApplic.Selection.TypeParagraph();
}
 
/// <summary>
/// 插入多個(gè)空行
/// </summary>
/// <param name="nline"></param>
public void InsertLineBreak(int nline)
{
for (int i = 0; i < nline; i++)
oWordApplic.Selection.TypeParagraph();
}
 
public void InsertPagebreak()
{
// VB : Selection.InsertBreak Type:=wdPageBreak
object pBreak = (int)Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;
oWordApplic.Selection.InsertBreak(ref pBreak);
}
 
// 插入頁碼
public void InsertPageNumber()
{
object wdFieldPage = Microsoft.Office.Interop.Word.WdFieldType.wdFieldPage;
object preserveFormatting = true;
oWordApplic.Selection.Fields.Add(oWordApplic.Selection.Range, ref wdFieldPage, ref missing, ref preserveFormatting);
}
 
// 插入頁碼
public void InsertPageNumber(string strAlign)
{
object wdFieldPage = Microsoft.Office.Interop.Word.WdFieldType.wdFieldPage;
object preserveFormatting = true;
oWordApplic.Selection.Fields.Add(oWordApplic.Selection.Range, ref wdFieldPage, ref missing, ref preserveFormatting);
SetAlignment(strAlign);
}
 
public void InsertImage(string strPicPath, float picWidth, float picHeight)
{
string FileName = strPicPath;
object LinkToFile = false;
object SaveWithDocument = true;
object Anchor = oWordApplic.Selection.Range;
//oWordApplic.ActiveDocument.InlineShapes.AddPicture(FileName, ref LinkToFile, ref SaveWithDocument, ref Anchor).Select();
//oWordApplic.Selection.InlineShapes[1].Width = picWidth; // 圖片寬度
//oWordApplic.Selection.InlineShapes[1].Height = picHeight; // 圖片高度
 
// 將圖片設(shè)置為四面環(huán)繞型
//Microsoft.Office.Interop.Word.Shape s = oWordApplic.Selection.InlineShapes[1].ConvertToShape();
//s.WrapFormat.Type = Microsoft.Office.Interop.Word.WdWrapType.wdWrapSquare;
 
//------------------------------ test ------------------------//
object left = 300;
object top = 200;
Object picW = 102;
Object picH = 126;
 
Microsoft.Office.Interop.Word.Shape sss = oWordApplic.ActiveDocument.Shapes.AddPicture(FileName, ref LinkToFile, ref SaveWithDocument, ref left, ref top, ref picW, ref picH, ref Anchor);
 
//------------------------------
}
 
//public void InsertLine(float left, float top, float width, float weight, int r, int g, int b)
//{
// //SetFontColor("red");
// //SetAlignment("Center");
// object Anchor = oWordApplic.Selection.Range;
// //int pLeft = 0, pTop = 0, pWidth = 0, pHeight = 0;
// //oWordApplic.ActiveWindow.GetPoint(out pLeft, out pTop, out pWidth, out pHeight,missing);
// //MessageBox.Show(pLeft + "," + pTop + "," + pWidth + "," + pHeight);
// object rep = false;
// //left += oWordApplic.ActiveDocument.PageSetup.LeftMargin;
// left = oWordApplic.CentimetersToPoints(left);
// top = oWordApplic.CentimetersToPoints(top);
// width = oWordApplic.CentimetersToPoints(width);
// Microsoft.Office.Interop.Word.Shape s = oWordApplic.ActiveDocument.Shapes.AddLine(0, top, width, top, ref Anchor);
// s.Line.ForeColor.RGB = RGB(r, g, b);
// s.Line.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
// s.Line.Style = Microsoft.Office.Core.MsoLineStyle.msoLineSingle;
// s.Line.Weight = weight;
//}
 
#endregion
 
#region 設(shè)置樣式
 
/// <summary>
/// Change the paragraph alignement
/// </summary>
/// <param name="strType"></param>
public void SetAlignment(string strType)
{
switch (strType.ToLower())
{
case "center":
oWordApplic.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
break;
case "left":
oWordApplic.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
break;
case "right":
oWordApplic.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;
break;
case "justify":
oWordApplic.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphJustify;
break;
}
 
}
 
 
// if you use thif function to change the font you should call it again with
// no parameter in order to set the font without a particular format
public void SetFont(string strType)
{
switch (strType)
{
case "Bold":
oWordApplic.Selection.Font.Bold = 1;
break;
case "Italic":
oWordApplic.Selection.Font.Italic = 1;
break;
case "Underlined":
oWordApplic.Selection.Font.Subscript = 0;
break;
}
}
 
// disable all the style
public void SetFont()
{
oWordApplic.Selection.Font.Bold = 0;
oWordApplic.Selection.Font.Italic = 0;
oWordApplic.Selection.Font.Subscript = 0;
 
}
 
public void SetFontName(string strType)
{
oWordApplic.Selection.Font.Name = strType;
}
 
public void SetFontSize(float nSize)
{
SetFontSize(nSize, 100);
}
 
public void SetFontSize(float nSize, int scaling)
{
if (nSize > 0f)
oWordApplic.Selection.Font.Size = nSize;
if (scaling > 0)
oWordApplic.Selection.Font.Scaling = scaling;
}
 
public void SetFontColor(string strFontColor)
{
switch (strFontColor.ToLower())
{
case "blue":
oWordApplic.Selection.Font.Color = Microsoft.Office.Interop.Word.WdColor.wdColorBlue;
break;
case "gold":
oWordApplic.Selection.Font.Color = Microsoft.Office.Interop.Word.WdColor.wdColorGold;
break;
case "gray":
oWordApplic.Selection.Font.Color = Microsoft.Office.Interop.Word.WdColor.wdColorGray875;
break;
case "green":
oWordApplic.Selection.Font.Color = Microsoft.Office.Interop.Word.WdColor.wdColorGreen;
break;
case "lightblue":
oWordApplic.Selection.Font.Color = Microsoft.Office.Interop.Word.WdColor.wdColorLightBlue;
break;
case "orange":
oWordApplic.Selection.Font.Color = Microsoft.Office.Interop.Word.WdColor.wdColorOrange;
break;
case "pink":
oWordApplic.Selection.Font.Color = Microsoft.Office.Interop.Word.WdColor.wdColorPink;
break;
case "red":
oWordApplic.Selection.Font.Color = Microsoft.Office.Interop.Word.WdColor.wdColorRed;
break;
case "yellow":
oWordApplic.Selection.Font.Color = Microsoft.Office.Interop.Word.WdColor.wdColorYellow;
break;
}
}
 
public void SetPageNumberAlign(string strType, bool bHeader)
{
object alignment;
object bFirstPage = false;
object bF = true;
//if (bHeader == true)
//WordApplic.Selection.HeaderFooter.PageNumbers.ShowFirstPageNumber = bF;
switch (strType)
{
case "Center":
alignment = Microsoft.Office.Interop.Word.WdPageNumberAlignment.wdAlignPageNumberCenter;
//WordApplic.Selection.HeaderFooter.PageNumbers.Add(ref alignment,ref bFirstPage);
//Microsoft.Office.Interop.Word.Selection objSelection = WordApplic.pSelection;
oWordApplic.Selection.HeaderFooter.PageNumbers[1].Alignment = Microsoft.Office.Interop.Word.WdPageNumberAlignment.wdAlignPageNumberCenter;
break;
case "Right":
alignment = Microsoft.Office.Interop.Word.WdPageNumberAlignment.wdAlignPageNumberRight;
oWordApplic.Selection.HeaderFooter.PageNumbers[1].Alignment = Microsoft.Office.Interop.Word.WdPageNumberAlignment.wdAlignPageNumberRight;
break;
case "Left":
alignment = Microsoft.Office.Interop.Word.WdPageNumberAlignment.wdAlignPageNumberLeft;
oWordApplic.Selection.HeaderFooter.PageNumbers.Add(ref alignment, ref bFirstPage);
break;
}
}
 
/// <summary>
/// 設(shè)置頁面為標(biāo)準(zhǔn)A4公文樣式
/// </summary>
private void SetA4PageSetup()
{
oWordApplic.ActiveDocument.PageSetup.TopMargin = oWordApplic.CentimetersToPoints(3.7f);
//oWordApplic.ActiveDocument.PageSetup.BottomMargin = oWordApplic.CentimetersToPoints(1f);
oWordApplic.ActiveDocument.PageSetup.LeftMargin = oWordApplic.CentimetersToPoints(2.8f);
oWordApplic.ActiveDocument.PageSetup.RightMargin = oWordApplic.CentimetersToPoints(2.6f);
//oWordApplic.ActiveDocument.PageSetup.HeaderDistance = oWordApplic.CentimetersToPoints(2.5f);
//oWordApplic.ActiveDocument.PageSetup.FooterDistance = oWordApplic.CentimetersToPoints(1f);
oWordApplic.ActiveDocument.PageSetup.PageWidth = oWordApplic.CentimetersToPoints(21f);
oWordApplic.ActiveDocument.PageSetup.PageHeight = oWordApplic.CentimetersToPoints(29.7f);
}
 
#endregion
 
#region 替換
 
///<summary>
/// 在word 中查找一個(gè)字符串直接替換所需要的文本
/// </summary>
/// <param name="strOldText">原文本</param>
/// <param name="strNewText">新文本</param>
/// <returns></returns>
public bool Replace(string strOldText, string strNewText)
{
if (oDoc == null)
oDoc = oWordApplic.ActiveDocument;
this.oDoc.Content.Find.Text = strOldText;
object FindText, ReplaceWith, Replace;//
FindText = strOldText;//要查找的文本
ReplaceWith = strNewText;//替換文本
Replace = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll;/**//*wdReplaceAll - 替換找到的所有項(xiàng)。
* wdReplaceNone - 不替換找到的任何項(xiàng)。
* wdReplaceOne - 替換找到的第一項(xiàng)。
* */
oDoc.Content.Find.ClearFormatting();//移除Find的搜索文本和段落格式設(shè)置
if (oDoc.Content.Find.Execute(
ref FindText, ref missing,
ref missing, ref missing,
ref missing, ref missing,
ref missing, ref missing, ref missing,
ref ReplaceWith, ref Replace,
ref missing, ref missing,
ref missing, ref missing))
{
return true;
}
return false;
}
 
public bool SearchReplace(string strOldText, string strNewText)
{
object replaceAll = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll;
 
//首先清除任何現(xiàn)有的格式設(shè)置選項(xiàng),然后設(shè)置搜索字符串 strOldText。
oWordApplic.Selection.Find.ClearFormatting();
oWordApplic.Selection.Find.Text = strOldText;
 
oWordApplic.Selection.Find.Replacement.ClearFormatting();
oWordApplic.Selection.Find.Replacement.Text = strNewText;
 
if (oWordApplic.Selection.Find.Execute(
ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing,
ref replaceAll, ref missing, ref missing, ref missing, ref missing))
{
return true;
}
return false;
}
 
#endregion
/// <summary>
/// rgb轉(zhuǎn)換函數(shù)
/// </summary>
/// <param name="r"></param>
/// <param name="g"></param>
/// <param name="b"></param>
/// <returns></returns>
int RGB(int r, int g, int b)
{
return ((b << 16) | (ushort)(((ushort)g << 8) | r));
}
 
Color RGBToColor(int color)
{
int r = 0xFF & color;
int g = 0xFF00 & color;
g >>= 8;
int b = 0xFF0000 & color;
b >>= 16;
return Color.FromArgb(r, g, b);
}
}

}

沈陽團(tuán)購網(wǎng)|營口網(wǎng)站制作|沈陽軟件公司|軟件定制|網(wǎng)站建設(shè)|加盟易勢|提交問題

日韩精品免费一区二区三区_久久精品国产三级不卡_免费观看中文字幕_好男人社区神马在线观看www
免费高清在线一区| 欧美精品尤物在线| 久久久久99| 欧美精品一区二区三区四区| 国产精品乱码| 1024欧美极品| 国产日韩亚洲| 国产精品啊v在线| 国产亚洲欧美一级| 篠田优中文在线播放第一区| 欧美成人视屏| 国产一区二区三区丝袜 | 亚洲欧美国产77777| 欧美国产乱视频| 好吊色欧美一区二区三区四区| 久久久久中文| 国产精品青草综合久久久久99| 亚洲欧美在线aaa| 欧美日本一区二区三区| 一区二区三区我不卡| 美女脱光内衣内裤视频久久网站| 国产嫩草影院久久久久| 久久精品国产视频| 国产精品五区| 久久全球大尺度高清视频| 国产女人水真多18毛片18精品视频| 欧美一区精品| 国产精品午夜电影| 久久久久久伊人| 国产女人精品视频| 另类春色校园亚洲| 狠狠综合久久| 欧美国产欧美亚洲国产日韩mv天天看完整 | 久久亚洲精品伦理| 国产精品欧美久久| 午夜精品三级视频福利| 欧美日韩在线一区| 欧美在线|欧美| 国产麻豆91精品| 免费成人美女女| 制服诱惑一区二区| 欧美日韩一区二区免费视频| 欧美亚洲日本国产| 国产美女一区| 欧美国产在线电影| 午夜激情亚洲| 国产欧美日韩麻豆91| 欧美成人r级一区二区三区| 亚洲深夜影院| 国产精品videossex久久发布| 久久精品免费播放| 黄网动漫久久久| 欧美日韩成人综合在线一区二区 | 好看的亚洲午夜视频在线| 欧美刺激性大交免费视频| 中文亚洲视频在线| 欧美亚一区二区| 久久久午夜视频| 在线精品视频免费观看| 欧美日韩18| 久久久久九九视频| 亚洲视频www| 国产精品日韩欧美一区二区三区| 老鸭窝亚洲一区二区三区| 亚洲午夜精品久久久久久浪潮| 欧美色偷偷大香| 久久在线免费观看| 亚洲一区二区三区在线看| 国产精自产拍久久久久久| 欧美黄色免费| 久久www免费人成看片高清 | 国产一区亚洲| 欧美日韩在线一区二区三区| 久久乐国产精品| 亚洲在线免费| 国产亚洲成人一区| 欧美日韩亚洲视频一区| 理论片一区二区在线| 午夜精品久久久久久久| 韩日欧美一区二区三区| 国产精品嫩草久久久久| 欧美大片在线观看一区| 久久久99免费视频| 亚洲专区在线视频| 国内精品视频666| 国产精品美女主播在线观看纯欲| 欧美精品性视频| 另类天堂视频在线观看| 小黄鸭精品aⅴ导航网站入口| 伊人久久噜噜噜躁狠狠躁| 国产美女在线精品免费观看| 欧美日韩综合在线| 欧美成人一区二区三区片免费| 欧美一区二区三区在线看| 永久免费精品影视网站| 国产一区二区精品在线观看| 国产精品福利在线观看| 欧美日韩dvd在线观看| 免费观看久久久4p| 久久蜜桃精品| 久久精品免视看| 欧美一区中文字幕| 亚洲综合电影一区二区三区| 精品电影在线观看| 韩国成人福利片在线播放| 国产日韩在线看| 国产精品永久入口久久久| 国产精品九九久久久久久久| 欧美日韩一区在线观看| 欧美日韩成人在线观看| 欧美黄色免费网站| 欧美电影免费观看高清| 猛干欧美女孩| 嫩草成人www欧美| 美女任你摸久久| 狂野欧美激情性xxxx| 久久综合电影一区| 久热re这里精品视频在线6| 久久久亚洲综合| 久久午夜精品一区二区| 久久午夜视频| 男人的天堂亚洲在线| 欧美h视频在线| 欧美大片va欧美在线播放| 你懂的国产精品| 欧美h视频在线| 欧美激情一区二区三区全黄 | 在线观看视频亚洲| 精品动漫一区| 亚洲视频日本| 亚洲免费视频一区二区| 亚洲综合色丁香婷婷六月图片| 亚洲一区二区av电影| 亚洲专区一二三| 欧美亚洲自偷自偷| 久久精品一区二区三区四区 | 亚洲色无码播放| 亚洲自拍电影| 性亚洲最疯狂xxxx高清| 久久精品国产第一区二区三区最新章节 | 激情成人av在线| 国产亚洲制服色| 合欧美一区二区三区| 黄色精品一区| 欧美日韩精品一区视频| 欧美视频在线观看免费网址| 欧美三级在线播放| 国产精品久久久久久户外露出| 欧美午夜精品理论片a级按摩| 国产精品入口尤物| 国模叶桐国产精品一区| 亚洲午夜一区| 欧美一区二区成人6969| 久久久久久一区二区| 免费视频一区| 欧美日韩在线精品| 国产女主播一区二区三区| 狠狠入ady亚洲精品经典电影| 亚洲无线观看| 欧美在线播放视频| 欧美成人精品一区| 国产精品ⅴa在线观看h| 国产一区二区日韩精品| 亚洲一区国产| 久久久久久久久久久久久久一区| 美女主播一区| 欧美三级第一页| 国际精品欧美精品| 午夜精品国产更新| 模特精品在线| 国产精品久线观看视频| 极品少妇一区二区三区精品视频| 欧美一级片一区| 欧美黑人在线播放| 国产精品网站视频| 中文欧美字幕免费| 久久久亚洲高清| 欧美日韩免费看| 国产三级欧美三级| 亚洲一二三区精品| 麻豆精品视频在线观看视频| 欧美三级小说| 黄色成人在线| 久久久久久久999| 欧美午夜不卡| 在线观看三级视频欧美| 久久久久99| 欧美性色视频在线| 精品99一区二区| 久久精品国产91精品亚洲| 欧美日本在线播放| 韩国av一区二区| 久久精品91久久久久久再现| 欧美裸体一区二区三区| 国产一区二区三区久久久| 午夜精品久久久久久久白皮肤| 欧美不卡高清| 国产精品资源在线观看| 欧美亚洲日本一区| 欧美日韩亚洲一区|