本文整理汇总了C#中System.Windows.Forms.Document.SaveAs方法的典型用法代码示例。如果您正苦于以下问题:C# Document.SaveAs方法的具体用法?C# Document.SaveAs怎么用?C# Document.SaveAs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Document
的用法示例。
在下文中一共展示了Document.SaveAs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddRegToSysResource
/// <summary>
/// put new regulation document into system resource and extract toc
/// </summary>
/// <param name="filepath"></param>
/// <returns></returns>
public Dictionary<string, List<TermContainer>> AddRegToSysResource(string filepath)
{
string fname = filepath.Substring(filepath.LastIndexOf("\\") + 1, filepath.LastIndexOf(".") - filepath.LastIndexOf("\\") - 1);
putNewRegTocInINIFile(fname);
ApplicationClass regWord = new ApplicationClass();
Document regDoc = new Document();
HandleDocument handleDocument = new HandleDocument();
regDoc = handleDocument.openDocument(filepath, regWord);
Table table = regDoc.Tables[1];
int rows = table.Rows.Count;
Dictionary<string, List<TermContainer>> dic = new Dictionary<string, List<TermContainer>>();
string key = "";
string section = "";
for(int i = 1;i<= rows;i++)
{
string text = getTableCellText(table, i, 1);
if (isLevel1Cell(text))
{
section = "";
key = text;
dic.Add(text, new List<TermContainer>());
}
else
{
if (isLevelSection(text))
{
section = text;
}
else
{
TermContainer term = getTableCellContainer(section,table, i);
dic[key].Add(term);
}
}
}
string path = System.Environment.CurrentDirectory;
string name = path + "\\resources\\"+regDoc.Name;
object saveAsName = path + "\\resources\\" + regDoc.Name;
object unknow = Type.Missing;
if (!File.Exists(name))
{
regDoc.SaveAs(ref saveAsName, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow);
}
else
{
//shifou ti huan
File.Delete(name);
regDoc.SaveAs(ref saveAsName, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow);
}
quit(regWord, regDoc);
return dic;
}
示例2: cmdViewContracts_Click
//.........这里部分代码省略.........
object missing = Type.Missing;
try
{
doc = word.Documents.Open(ref sourcefile, 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);
doc.Activate();
if (!Utilities.Replace_String_In_Word_File(ref doc, "#TEN KHACH HANG#", benvay))
{
doc.Close(ref missing, ref missing, ref missing);
word.Application.Quit(ref missing, ref missing, ref missing);
return;
//doc.SaveAs(ref destfile, 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);
}
if (!Utilities.Replace_String_In_Word_File(ref doc, "#Dia chi khach hang#", Diachi))
{
doc.Close(ref missing, ref missing, ref missing);
word.Application.Quit(ref missing, ref missing, ref missing);
}
if (!Utilities.Replace_String_In_Word_File(ref doc, "#Dien thoai#", soDT))
{
doc.Close(ref missing, ref missing, ref missing);
word.Application.Quit(ref missing, ref missing, ref missing);
}
if (!Utilities.Replace_String_In_Word_File(ref doc, "#Tong so tien#", sotien))
{
doc.Close(ref missing, ref missing, ref missing);
word.Application.Quit(ref missing, ref missing, ref missing);
}
if (!Utilities.Replace_String_In_Word_File(ref doc, "#Laisuat#", laisuat))
{
doc.Close(ref missing, ref missing, ref missing);
word.Application.Quit(ref missing, ref missing, ref missing);
}
if (!Utilities.Replace_String_In_Word_File(ref doc, "#Thoihan#", kyhan))
{
doc.Close(ref missing, ref missing, ref missing);
word.Application.Quit(ref missing, ref missing, ref missing);
}
if (!Utilities.Replace_String_In_Word_File(ref doc, "#Donvi#", cbxDonvitinh.Text))
{
doc.Close(ref missing, ref missing, ref missing);
word.Application.Quit(ref missing, ref missing, ref missing);
}
if (!Utilities.Replace_String_In_Word_File(ref doc, "#Ngayhopdong#", cbxDateContracts.Value.ToShortDateString()))
{
doc.Close(ref missing, ref missing, ref missing);
word.Application.Quit(ref missing, ref missing, ref missing);
}
if (!Utilities.Replace_String_In_Word_File(ref doc, "#Ngaydaohan#", ngaydaohan.ToShortDateString()))
{
doc.Close(ref missing, ref missing, ref missing);
word.Application.Quit(ref missing, ref missing, ref missing);
}
if (!Utilities.Replace_String_In_Word_File(ref doc, "#Phiuythacvon#", txtPhiUT.Text))
{
doc.Close(ref missing, ref missing, ref missing);
word.Application.Quit(ref missing, ref missing, ref missing);
}
if (!Utilities.Replace_String_In_Word_File(ref doc, "#Account Numver#", BankAccount))
{
doc.Close(ref missing, ref missing, ref missing);
word.Application.Quit(ref missing, ref missing, ref missing);
}
if (!Utilities.Replace_String_In_Word_File(ref doc, "#Bank Name#", BankName))
{
doc.Close(ref missing, ref missing, ref missing);
word.Application.Quit(ref missing, ref missing, ref missing);
}
if (!Utilities.Replace_String_In_Word_File(ref doc, "#Loinhuan#", strLoinhuan))
{
doc.Close(ref missing, ref missing, ref missing);
word.Application.Quit(ref missing, ref missing, ref missing);
}
doc.SaveAs(ref destfile, 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);
doc.Close(ref missing, ref missing, ref missing);
word.Application.Quit(ref missing, ref missing, ref missing);
Proc.StartInfo.FileName = @"WINWORD.EXE";
Proc.StartInfo.Arguments = destfile.ToString();
Proc.Start();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
doc.Close(ref missing, ref missing, ref missing);
word.Application.Quit(ref missing, ref missing, ref missing);
}
}