Office中国论坛/Access中国论坛
标题:
【作业】@VSTO易#初级班01期#第05课
[打印本页]
作者:
pengjia89
时间:
2014-4-7 21:52
标题:
【作业】@VSTO易#初级班01期#第05课
[attach]53781[/attach]
作者:
闻启学
时间:
2014-4-8 17:49
先完成两个先
1,
private void button2_Click(object sender, RibbonControlEventArgs e)
{
//插入字符串
int iIngEnd = GetWordApp().ActiveDocument.Paragraphs[3].Range.End;
int iIngStart = GetWordApp().ActiveDocument.Paragraphs[3].Range.Start;
GetWordApp().ActiveDocument.Range(iIngStart, iIngEnd).InsertAfter("西西师傅!我来了");
}
复制代码
2,
private void button3_Click(object sender, RibbonControlEventArgs e)
{
//删除嵌入图片
foreach (var item in GetWordApp().ActiveDocument.InlineShapes)
{
InlineShape aa = item as InlineShape;
aa.Delete();
}
}
复制代码
作者:
microfaint
时间:
2014-4-11 20:40
留名占地
作者:
闻启学
时间:
2014-4-11 21:21
3
private void btnMail_Click(object sender, RibbonControlEventArgs e)
{
//将每个记录自动生成每个文档 文件名称以第一个字段命名
Word.MailMerge Mymer = GetWordApp().ActiveDocument.MailMerge;
string fildName = "";
if (GetWordApp().ActiveDocument.MailMerge == null)
{
return;
}
if (Mymer.State == WdMailMergeState.wdMainAndDataSource)
{
Mymer.DataSource.ActiveRecord = WdMailMergeActiveRecord.wdFirstRecord;
for (int i = 1; i <= Mymer.DataSource.RecordCount; i++)
{
Mymer.DataSource.FirstRecord = i;
Mymer.DataSource.LastRecord = i;
Mymer.Destination = WdMailMergeDestination.wdSendToNewDocument;
fildName = Mymer.DataSource.DataFields[1].Value; //可以选择字段?
Mymer.DataSource.ActiveRecord = WdMailMergeActiveRecord.wdNextRecord;
Mymer.Execute();
GetWordApp().ActiveDocument.Content.Characters.Last.Previous().Delete();
string myDocPath = @"I:\test"; //可以选择路径?
try
{
GetWordApp().ActiveDocument.SaveAs(FileName: myDocPath + fildName + ".doc");
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
GetWordApp().ActiveDocument.Close();
}
}
}
复制代码
作者:
Amas
时间:
2014-4-13 01:16
提交作业:
http://www.office-cn.net/forum.p ... 2&fromuid=14932
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/)
Powered by Discuz! X3.3