91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 162KB
    文件類型: .rar
    金幣: 1
    下載: 0 次
    發布日期: 2021-06-16
  • 語言: C#
  • 標簽: C#??word??圖片??

資源簡介

C#在word中插入圖片,可以方便對word文檔的圖片操作

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.Threading;
using?Office?=?Microsoft.Office.Core;
using?Word?=?Microsoft.Office.Interop.Word;

namespace?AddImage
{
????public?partial?class?Frm_Main?:?Form
????{
????????public?Frm_Main()
????????{
????????????InitializeComponent();
????????}

????????private?Word.Application?G_wa;//定義Word應用程序字段
????????private?object?G_missing?=?//定義missing字段并賦值
????????????System.Reflection.Missing.Value;
????????private?object?G_str_path;//定義文件保存路徑字段
????????private?OpenFileDialog?G_OpenFileDialog;//定義打開文件對話框字段
????????private?FolderBrowserDialog?G_FolderBrowserDialog;//定義文件夾瀏覽對話框字段

????????private?void?btn_Select_Click(object?sender?EventArgs?e)
????????{
????????????G_FolderBrowserDialog?=//創建瀏覽文件夾對象
??????????????new?FolderBrowserDialog();
????????????DialogResult?P_DialogResult?=?//瀏覽文件夾
????????????????G_FolderBrowserDialog.ShowDialog();
????????????if?(P_DialogResult?==?DialogResult.OK)//確認已經選擇文件夾
????????????{
????????????????btn_New.Enabled?=?true;//啟用新建按鈕
????????????????txt_path.Text?=?//顯示選擇路徑
????????????????????G_FolderBrowserDialog.SelectedPath;
????????????}
????????}

????????private?void?btn_Image_Click(object?sender?EventArgs?e)
????????{
????????????G_OpenFileDialog?=//創建瀏覽文件夾對象
?????????????????new?OpenFileDialog();
????????????DialogResult?P_DialogResult?=?//瀏覽文件夾
????????????????G_OpenFileDialog.ShowDialog();
????????????if?(P_DialogResult?==?DialogResult.OK)//確認已經選擇文件夾
????????????{
????????????????txt_ImagePath.Text?=//顯示選擇路徑
????????????????????G_OpenFileDialog.FileName;
????????????????btn_Select.Enabled?=?true;//啟用瀏覽文檔按鈕
????????????????this.Width?=?553;//設置窗體寬度
????????????????pbox_Image.Image?=?//顯示圖片
????????????????????Image.FromFile(G_OpenFileDialog.FileName);
????????????}
????????}

????????private?void?btn_New_Click(object?sender?EventArgs?e)
????????{
????????????btn_New.Enabled?=?false;//停用新建按鈕
????????????ThreadPool.QueueUserWorkItem(//使用線程池
????????????????(P_temp)?=>//使用lambda表達式
????????????????{
????????????????????G_wa?=?new?Word.Application();//創建Word應用程序對象
????????????????????Word.Document?P_wd?=?G_wa.Documents.Add(//建立新文檔
????????????????????????ref?G_missing?ref?G_missing?ref?G_missing?ref?G_missing);
????????????????????Word.Range?P_Range?=?P_wd.Paragraphs[1].Range;//得到段落范圍
????????????????????object?P_Ranges?=?P_Range;//創建ojbect對象
????????????????????P_wd.InlineShapes.AddPicture(//向文檔中插入圖片
????????????????????????G_OpenFileDialog.FileName?ref?G_missing?ref?G_missing?ref?P_Ranges);
????????????????????G_str_path?=?string.Format(//計算文件保存路徑
????????????????????????@“{0}\{1}“?G_FolderBrowserDialog.SelectedPath
????????????????????????DateTime.Now.ToString(“yyyy年M月d日h時s分m秒fff毫秒“)?+?“.doc“);
????????????????????P_wd.SaveAs(//保存Word文件
????

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????4712??2010-06-12?15:30??AddImage\AddImage.csproj

?????文件??????12800??2010-07-02?11:59??AddImage\bin\Debug\AddImage.exe

?????文件??????24064??2010-07-02?11:59??AddImage\bin\Debug\AddImage.pdb

?????文件??????14328??2010-06-12?14:54??AddImage\bin\Debug\AddImage.vshost.exe

?????文件????????490??2009-06-11?05:14??AddImage\bin\Debug\AddImage.vshost.exe.manifest

?????文件???????4965??2010-07-02?11:59??AddImage\Frm_Main.cs

?????文件???????8674??2010-06-13?11:41??AddImage\Frm_Main.Designer.cs

?????文件???????5814??2010-06-13?11:41??AddImage\Frm_Main.resx

?????文件????????988??2010-07-02?11:59??AddImage\obj\Debug\AddImage.csproj.FileListAbsolute.txt

?????文件????????850??2010-07-02?11:59??AddImage\obj\Debug\AddImage.csproj.GenerateResource.Cache

?????文件???????1071??2010-11-05?14:58??AddImage\obj\Debug\AddImage.csproj.ResolveComReference.cache

?????文件??????12800??2010-07-02?11:59??AddImage\obj\Debug\AddImage.exe

?????文件????????180??2010-07-02?11:59??AddImage\obj\Debug\AddImage.Frm_Main.resources

?????文件??????24064??2010-07-02?11:59??AddImage\obj\Debug\AddImage.pdb

?????文件????????180??2010-07-02?11:59??AddImage\obj\Debug\AddImage.Properties.Resources.resources

?????文件?????409600??2010-07-02?11:59??AddImage\obj\Debug\Interop.Microsoft.Office.Core.dll

?????文件?????155648??2010-11-05?14:58??AddImage\obj\Debug\Interop.Office.dll

?????文件????????492??2010-06-12?15:29??AddImage\Program.cs

?????文件???????1348??2010-06-12?14:43??AddImage\Properties\AssemblyInfo.cs

?????文件???????2866??2010-06-12?14:43??AddImage\Properties\Resources.Designer.cs

?????文件???????5612??2010-06-12?14:43??AddImage\Properties\Resources.resx

?????文件???????1093??2010-06-12?14:43??AddImage\Properties\Settings.Designer.cs

?????文件????????249??2010-06-12?14:43??AddImage\Properties\Settings.settings

?????目錄??????????0??2010-11-09?15:04??AddImage\obj\Debug\Refactor

?????目錄??????????0??2010-11-09?15:04??AddImage\obj\Debug\TempPE

?????目錄??????????0??2014-01-08?10:07??AddImage\bin\Debug

?????目錄??????????0??2014-01-08?10:07??AddImage\obj\Debug

?????目錄??????????0??2014-01-08?10:07??AddImage\bin

?????目錄??????????0??2014-01-08?10:07??AddImage\obj

?????目錄??????????0??2014-01-08?10:07??AddImage\Properties

............此處省略4個文件信息

評論

共有 條評論