影音先锋男人每日资源站_精品国产免费久久久久久尖叫_久久久久久成人_国产精品福利网站

注冊|登錄

聯系電話:024-31891684  13390130939
沈陽軟件公司--沈陽軟件定制

沈陽軟件開發_沈陽軟件公司_沈陽軟件定制/軟件/最新技術

Latest technology最新技術

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

瀏覽量:4887

通過替換模板中的指定 書簽 來進行內容的替換、整合,然后直接發送到打印打印,也可以導出。即把打印出的語句換成保存函數。

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進程
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);
}
}

 

 


 

 

針對一些問內容替換或其他操作word的問題,我整理了一個類,里面的方法應該夠用的了,里面有文字的替換,圖片的插入等等。

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();
}
 
//對標簽"Content"進行填充
//直接寫入內容不能識別表格什么的
//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文檔,并且返回對象oDoc
/// 完整Word文件路徑+名稱
/// 返回的Word.Document oDoc對象
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 + "'已經存在,選確定覆蓋原文件,選取消退出操作!", "警告", 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保存為單個網頁文件
//wdFormatFilteredHTML保存為過濾掉word標簽的htm文件,缺點是有圖片的話會產生網頁文件夾
if (File.Exists(strFileName))
{
if (MessageBox.Show("文件'" + strFileName + "'已經存在,選確定覆蓋原文件,選取消退出操作!", "警告", 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 添加菜單(工具欄)項
 
////添加單獨的菜單項
//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);
// }
//}
 
////添加單獨工具欄
//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 移動光標位置
 
// 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>
/// 插入多個空行
/// </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; // 圖片高度
 
// 將圖片設置為四面環繞型
//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 設置樣式
 
/// <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>
/// 設置頁面為標準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 中查找一個字符串直接替換所需要的文本
/// </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 - 替換找到的所有項。
* wdReplaceNone - 不替換找到的任何項。
* wdReplaceOne - 替換找到的第一項。
* */
oDoc.Content.Find.ClearFormatting();//移除Find的搜索文本和段落格式設置
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;
 
//首先清除任何現有的格式設置選項,然后設置搜索字符串 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轉換函數
/// </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);
}
}

}

沈陽團購網|營口網站制作|沈陽軟件公司|軟件定制|網站建設|加盟易勢|提交問題

91美女福利视频高清| 一区国产精品视频| 毛片在线免费视频| 日本欧洲一区二区| 久久人妻精品白浆国产| 日韩欧国产精品一区综合无码| 国产精品视频一区国模私拍 | 日韩在线一区二区三区免费视频| 成人男女网免费| 亚洲乱码国产乱码精品精98午夜| 波多野结衣亚洲一区二区| 夜久久久久久| wwww.国产| 国产厕拍一区| 欧美日本亚洲| 丁香高清在线观看完整电影视频| 欧美精品久久久久久久免费观看| 黄网在线观看网址入口| 欧美性淫爽ww久久久久无| 亚洲香蕉在线视频| 久久久久国产免费免费| 黑鬼狂亚洲人videos| 午夜一级久久| 中文字幕 日韩 欧美| 国产成人精品一区二区免费看京 | 麻豆视频在线免费看| 亚洲在线日韩| 怡红院亚洲色图| 北条麻妃国产九九九精品小说| 在线观看日本一区| 新片速递亚洲合集欧美合集| yellow视频在线观看一区二区| av片在线看| 久久久久国产精品免费| 欧美知名女优| xxav国产精品美女主播| 美女黄色网址| 日韩经典中文字幕在线观看| 欧美性猛交xxxx免费看手交| 色综合天天视频在线观看| 精品国产无码一区二区三区| 亚洲欧洲www| 亚洲不卡视频在线观看| 国产婷婷色一区二区三区在线| 丰满少妇被猛烈进入一区二区| 久久99热狠狠色一区二区| 男人天堂av电影| 久久午夜视频| 人妻av一区二区| 亚洲人成毛片在线播放女女| 免费一区二区三区在线观看| 欧美精品一区二区久久| 久久精品一区二| 黄色不卡一区| 欧美日韩一道本| 一区二区三区视频免费观看| 可以免费看的黄色网址| 99精品视频在线免费播放 | 中文精品在线观看| 99久久亚洲精品蜜臀| 99在线观看视频免费| 69堂免费精品视频在线播放| 国产女人水真多18毛片18精品| 在线观看a级片| 国产精品视频xxxx| 91最新在线视频| 国产一区二区香蕉| av大全在线| 福利视频一区二区三区| 乱插在线www| av免费观看久久| 日韩电影免费观| 久久99国产精品99久久| 欧美专区福利免费| 色综合电影网| 国产 日韩 欧美| 三年中国中文在线观看免费播放| 国产精品色呦| 日本香蕉视频在线观看| 国产精品毛片久久久| 国产日韩av网站| 欧美禁忌电影| 黄色免费视频大全| 91久久电影| 一级片免费在线观看视频| 欧美日韩亚洲一区三区| 性欧美丰满熟妇xxxx性久久久| 久久一二三四| 黄色av片三级三级三级免费看| 国产精品一区二区不卡| 印度午夜性春猛xxx交| 久久久久久久一区| 中文无码av一区二区三区| 一区二区三区日韩| 国 产 黄 色 大 片| 欧美日韩免费看| 亚洲天堂久久久| 精品国产91乱码一区二区三区| 九色视频网址| 影音先锋日韩有码| 小小水蜜桃在线观看| 国产国语刺激对白av不卡| 26uuu亚洲电影在线观看| 久久久久久a亚洲欧洲aⅴ| 色综合视频一区二区三区日韩| 亚洲欧美日韩不卡| 菠萝蜜一区二区| www.五月天色| 久久精品一区二区三区中文字幕 | 日韩午夜精品| 波多野结衣av在线观看| 成人丝袜18视频在线观看| aaa人片在线| 有坂深雪av一区二区精品| 好男人官网在线观看| 日韩视频一区二区三区| 比比资源先锋| 国内精品小视频| 在线三级中文| 欧美裸体网站| 国产剧情一区| 亚洲一区二区三区四区精品| 蜜臀久久久久久久| 欧美日韩中文视频| 亚洲女同一区二区| 亚洲人妻一区二区| 亚洲精品国精品久久99热一| 男人天堂av网站| 国产精品色视频| 日韩一区精品| 久久视频这里有精品| a91a精品视频在线观看| 国产黄色录像视频| 亚洲色图另类专区| 99re5久久在热线播放| 日韩在线中文| 青青青青草视频| aa国产精品| 国产91在线播放九色| 亚洲综合精品| 妺妺窝人体色www婷婷| 亚洲同性同志一二三专区| а√中文在线资源库| 亚洲第一区中文99精品| 国产黄色片大全| 97久久国产精品| 欧美片第1页| 激情五月婷婷六月| 欧美区日韩区| a级黄色免费视频| 国产亚洲综合性久久久影院| www天堂在线| 亚洲国产欧美久久| 未来日记在线观看| 乱色588欧美| 国产一区二区三区四区二区| 中文字幕一区二区在线观看视频| 毛片不卡一区二区| 国产成人无码精品久久久久| 亚洲精品一二三四区| 国产精品伦一区二区三区级视频频| 日韩中文字幕不卡视频| jizz日韩| 日韩一区二区三区资源| 色97色成人| 999精品视频在线观看播放| 亚洲免费成人av| 国产精品免费麻豆入口| 97精品视频在线| a毛片不卡免费看片| 加勒比海盗1在线观看免费国语版| 亚洲激情女人| 久操免费在线视频| 一区二区三区色| 黄色免费网站观看| 欧美最猛性xxxxx亚洲精品| 亚洲精品大全| 红桃视频 国产| 成人精品国产一区二区4080| 大陆av在线播放| 国产永久免费| 一区二区三区精品视频在线观看 | 毛片手机在线观看| jlzzjlzz国产精品久久| 热草久综合在线| 五月天婷婷激情| 亚洲色图美女| 免费看国产曰批40分钟| 日韩av一区二区三区四区| 一区二区日韩在线观看| 亚洲国产天堂久久综合网| av网站在线免费观看| 日本免费在线视频观看| 久久久久看片| 国产巨乳在线观看| 国产亚洲美女久久| 999av小视频在线| 欧美日韩亚洲一二三| 成人激情文学综合网| 久久全国免费久久青青小草 |