最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#創(chuàng)建一個Word并打開的方法

 更新時間:2015年04月14日 09:37:38   作者:Regina  
這篇文章主要介紹了C#創(chuàng)建一個Word并打開的方法,實例分析了C#操作word的常用技巧,非常具有實用價值,需要的朋友可以參考下

本文實例講述了C#創(chuàng)建一個Word并打開的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:

復制代碼 代碼如下:
private static string _createNewWord(string allTnC)
{
    Microsoft.Office.Interop.Word.Document wordDocument = null;
    Microsoft.Office.Interop.Word.Application wordApplication = null;
    string dateTimeNow = DateTime.Now.ToString();
    string wordPath = Path.GetTempFileName();
    wordApplication = new Word.ApplicationClass();
    object nothing = Missing.Value;
    wordDocument = wordApplication.Documents.Add(ref nothing, ref nothing, ref nothing, ref nothing);
    wordDocument.Paragraphs.Last.Range.Text = allTnC;
    object format = Word.WdSaveFormat.wdFormatDocumentDefault;
    wordDocument.SaveAs(wordPath, ref format, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing,
 ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing);
    wordDocument.Application.Documents.Close(ref nothing, ref nothing, ref nothing);
    ((Word.ApplicationClass)wordApplication).Quit(ref nothing, ref nothing, ref nothing);
    return wordPath;
}
private static void _importTnCToActiveDocument(string wordPath)
{
    Word.Application wordApplication = new Word.Application();
    Word.Document wordDocument = new Word.Document();
    Object nothing = System.Reflection.Missing.Value;
    Object filePath = wordPath;
    wordApplication.Documents.Open(ref filePath, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref   nothing, ref   nothing, ref   nothing, ref   nothing, ref  nothing, ref   nothing, ref   nothing);
    wordDocument = wordApplication.ActiveDocument;
    wordApplication.Visible = true;
}

vs10-office項目中創(chuàng)建ThisAddIn按鈕實現(xiàn)某些功能當打開多個word時便獲取不到當前word文檔對象(如需要獲取打開的第一個文檔中的bookmark)

可以在 Startup 中加入:

ViteRibbon viteRibbon = new ViteRibbon(this.Application);

構造函數傳遞該參數并賦值:

currentDoucment = wordApp.ActiveDocument;

希望本文所述對大家的C#程序設計有所幫助。

相關文章

  • unity 如何判斷鼠標是否在哪個UI上(兩種方法)

    unity 如何判斷鼠標是否在哪個UI上(兩種方法)

    這篇文章主要介紹了unity 判斷鼠標是否在哪個UI上的兩種實現(xiàn)方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2021-04-04
  • c#文檔圖片自動糾偏

    c#文檔圖片自動糾偏

    最近找到一個不錯的文檔圖片自動糾偏的方法,現(xiàn)在跟大家分享一下,需要的朋友可以參考下
    2014-03-03
  • C#使用LINQ查詢文件列表并找出最大文件

    C#使用LINQ查詢文件列表并找出最大文件

    在現(xiàn)代 C# 開發(fā)中,LINQ (Language Integrated Query) 提供了一種強大而優(yōu)雅的方式來處理集合數據,本文將詳細介紹如何使用 LINQ 查詢文件系統(tǒng)中的文件,并找出最大的文件數量,需要的朋友可以參考下
    2024-10-10
  • C#動態(tài)加載dll擴展系統(tǒng)功能的方法

    C#動態(tài)加載dll擴展系統(tǒng)功能的方法

    這篇文章主要介紹了C#動態(tài)加載dll擴展系統(tǒng)功能的方法,涉及C#動態(tài)加載dll擴展的相關技巧,需要的朋友可以參考下
    2015-04-04
  • C# 遍歷枚舉類型的所有元素

    C# 遍歷枚舉類型的所有元素

    寫個小東西,剛好用到枚舉類型,需要顯示在DropDownList控件中。嘗試了下,用如下方法可以實現(xiàn)
    2013-03-03
  • Unity中的Tilemap流程分析

    Unity中的Tilemap流程分析

    這篇文章給大家介紹Unity中的Tilemap流程分析,本文通過圖文并茂的形式給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友參考下吧
    2021-07-07
  • C#設計模式之觀察者模式實例講解

    C#設計模式之觀察者模式實例講解

    這篇文章主要介紹了C#設計模式之觀察者模式實例講解,本文詳細講解了觀察者模式的定義、優(yōu)缺點、代碼實例等,需要的朋友可以參考下
    2014-10-10
  • java和c#使用hessian通信的方法

    java和c#使用hessian通信的方法

    這篇文章主要介紹了java和c#使用hessian通信的方法,服務器端為Java,客戶端為C#實現(xiàn)。是一個非常實用的技巧,需要的朋友可以參考下
    2014-09-09
  • c# 通過代碼開啟或關閉防火墻

    c# 通過代碼開啟或關閉防火墻

    這篇文章主要介紹了c# 通過代碼開啟或關閉防火墻的示例,幫助大家更好的理解和使用c#,感興趣的朋友可以了解下
    2020-10-10
  • 分享WCF文件傳輸實現(xiàn)方法---WCFFileTransfer

    分享WCF文件傳輸實現(xiàn)方法---WCFFileTransfer

    這篇文章主要介紹了分享WCF文件傳輸實現(xiàn)方法---WCFFileTransfer,需要的朋友可以參考下
    2015-11-11

最新評論

鹰潭市| 青州市| 平和县| 东明县| 盱眙县| 当雄县| 休宁县| 五河县| 宝山区| 永州市| 夏邑县| 淮安市| 六盘水市| 子长县| 东兰县| 修武县| 南召县| 武强县| 三都| 独山县| 东阳市| 高邮市| 昭苏县| 津市市| 沁水县| 东至县| 洪江市| 永和县| 隆回县| 武胜县| 开封市| 茌平县| 玉环县| 胶南市| 宝应县| 霸州市| 新乡市| 青田县| 东乌| 遂平县| 涞水县|