本文整理匯總了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);
}
}