本文整理汇总了C#中Microsoft.Office.Interop.Word.Close方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Office.Interop.Word.Close方法的具体用法?C# Microsoft.Office.Interop.Word.Close怎么用?C# Microsoft.Office.Interop.Word.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Office.Interop.Word
的用法示例。
在下文中一共展示了Microsoft.Office.Interop.Word.Close方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
//.........这里部分代码省略.........
doc.Tables[1].Cell(3, 2).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
doc.Tables[1].Cell(3, 3).Range.Text = "3";
doc.Tables[1].Cell(3, 3).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
doc.Tables[1].Cell(3, 4).Range.Text = "4";
doc.Tables[1].Cell(3, 4).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
doc.Tables[1].Cell(3, 5).Range.Text = "5";
doc.Tables[1].Cell(3, 5).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
doc.Tables[1].Cell(3, 6).Range.Text = "6";
doc.Tables[1].Cell(3, 6).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
// Заполняем продукты
for (int i = 0; i < document.Products.Count; i++)
{
if (!isWork) break;
doc.Tables[1].Cell(i + 4, 1).Range.Text = Convert.ToString(i + 1) + '.';
doc.Tables[1].Cell(i + 4, 1).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
doc.Tables[1].Cell(i + 4, 2).Range.Text = document.Products.ElementAt(i).Name;
doc.Tables[1].Cell(i + 4, 2).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphJustify;
doc.Tables[1].Cell(i + 4, 5).Range.Text = document.Products.ElementAt(i).TradeMark;
doc.Tables[1].Cell(i + 4, 5).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphJustify;
// Получим свойства продукта на шаблон
//Product productTest = document.Products.ElementAt(i);
//IColl<Param> paramsTemplate = mvm.dc.Templates.FirstOrDefault(p => p.Name.Trim().ToLower() == "свобода").Param;
//ICollection<Property> productProperties = document.Products.ElementAt(i).SelectMany(m => m.ParamValues.Where(l => l.Param.Template.Name.Trim().ToLower() == "свобода"));
//ICollection<Param> paramColl = (ICollection<Param>)paramsTemplate;
var myTemplate = document.Products.ElementAt(i).Templates.FirstOrDefault(m => m.Name.Trim().ToLower() == "свобода");
IEnumerable<Property> productProperties = document.Products.ElementAt(i).Properties.SelectMany(m => m.ParamValues.Where(p => myTemplate.Param.Contains(p.Param))).Select(f => f.Property).Distinct();
// В данном шаблоне одно свойство(строка) у продукта
if (productProperties.Count() != 1)
{
message = "Ошибка при составлении шаблона";
return ResultType_enum.Error;
}
Property property = productProperties.First();
ParamValue paramValue = null;
// Требования заказчика
paramValue = property.ParamValues.FirstOrDefault(m => m.Param.Name == "Требования заказчика");
if (paramValue != null)
{
doc.Tables[1].Cell(i + 4, 3).Range.Text = paramValue.Value;
}
else
{
doc.Tables[1].Cell(i + 4, 3).Range.Text = "";
}
doc.Tables[1].Cell(i + 4, 3).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphJustify;
// Требования участника
paramValue = property.ParamValues.FirstOrDefault(m => m.Param.Name == "Требования участника");
if (paramValue != null)
{
doc.Tables[1].Cell(i + 4, 4).Range.Text = paramValue.Value;
}
else
{
doc.Tables[1].Cell(i + 4, 4).Range.Text = "";
}
doc.Tables[1].Cell(i + 4, 4).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphJustify;
// Сертификация
paramValue = property.ParamValues.FirstOrDefault(m => m.Param.Name == "Сертификация");
if (paramValue != null)
{
doc.Tables[1].Cell(i + 4, 6).Range.Text = paramValue.Value;
}
else
{
doc.Tables[1].Cell(i + 4, 6).Range.Text = "";
}
doc.Tables[1].Cell(i + 4, 6).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphJustify;
}
application.Visible = true;
}
catch (Exception er)
{
if (doc != null)
doc.Close(ref falseObj, ref missingObj, ref missingObj);
doc = null;
}
return ResultType_enum.Done;
}
catch (Exception ex)
{
doc = null;
message = ex.Message + '\n' + ex.StackTrace;
return ResultType_enum.Error;
}
finally
{
isWork = false;
}
}
示例2: Close
/// <summary>
/// 关闭文档
/// </summary>
/// <param name="wDoc">Document对象</param>
/// <param name="WApp">Application对象</param>
public static void Close(Word.Document wDoc, Word.Application WApp)
{
Object SaveChanges = Word.WdSaveOptions.wdSaveChanges;// 指定文档的保存操作。可以是下列 WdSaveOptions 值之一:wdDoNotSaveChanges、wdPromptToSaveChanges 或 wdSaveChanges。
Object OriginalFormat = Word.WdOriginalFormat.wdOriginalDocumentFormat;// 指定文档的保存格式。可以是下列 WdOriginalFormat 值之一:wdOriginalDocumentFormat、wdPromptUser 或 wdWordDocument。
Object RouteDocument = false;// 如果为 true,则将文档传送给下一个收件人。如果没有为文档附加传送名单,则忽略此参数。
try
{
if (wDoc != null) wDoc.Close(ref SaveChanges, ref OriginalFormat, ref RouteDocument);
if (WApp != null) WApp.Quit(ref SaveChanges, ref OriginalFormat, ref RouteDocument);
}
catch (Exception ex)
{
throw ex;
}
}
示例3: closeDocument
private void closeDocument(Word.Document doc)
{
object SaveChanges = Word.WdSaveOptions.wdSaveChanges;
doc.Close(ref SaveChanges);
}
示例4: CloseDoc
private static void CloseDoc(Word.Document doc)
{
if (doc != null)
{
object saveChanges = Word.WdSaveOptions.wdSaveChanges;
object originalFormat = Word.WdOriginalFormat.wdOriginalDocumentFormat;
object routeDocument = false;
doc.Close(ref saveChanges, ref originalFormat, ref routeDocument);
}
//DirectoryInfo dir = new DirectoryInfo(TEMP_PATH);
//foreach (FileInfo file in dir.GetFiles())
// file.Delete();
//dir.Delete(true);
}
示例5: Create
//.........这里部分代码省略.........
doc.Tables[1].Cell(i + 4, 1).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
doc.Tables[1].Cell(i + 4, 2).Range.Text = document.Products.ElementAt(productIndexCompilator).Name;
doc.Tables[1].Cell(i + 4, 2).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphJustify;
doc.Tables[1].Cell(i + 4, 3).Range.Text = document.Products.ElementAt(productIndexCompilator).TradeMark;
doc.Tables[1].Cell(i + 4, 3).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphJustify;
// Сертификация
paramValue = productProperties.ElementAt(propertyIndexCompilator).ParamValues.FirstOrDefault(m => m.Param.Name == "Сертификация");
if (paramValue != null)
{
doc.Tables[1].Cell(i + 4, 8).Range.Text = paramValue.Value;
}
else
{
doc.Tables[1].Cell(i + 4, 8).Range.Text = "";
}
doc.Tables[1].Cell(i + 4, 8).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
}
// Требуемый параметр
paramValue = productProperties.ElementAt(propertyIndexCompilator).ParamValues.FirstOrDefault(m => m.Param.Name == "Требуемый параметр");
if (paramValue != null)
{
doc.Tables[1].Cell(i + 4, 4).Range.Text = paramValue.Value;
}
else
{
doc.Tables[1].Cell(i + 4, 4).Range.Text = "";
}
doc.Tables[1].Cell(i + 4, 4).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
// Требуемое значение
paramValue = productProperties.ElementAt(propertyIndexCompilator).ParamValues.FirstOrDefault(m => m.Param.Name == "Требуемое значение");
if (paramValue != null)
{
doc.Tables[1].Cell(i + 4, 5).Range.Text = paramValue.Value;
}
else
{
doc.Tables[1].Cell(i + 4, 5).Range.Text = "";
}
doc.Tables[1].Cell(i + 4, 5).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
// Значение, предлагаемое участником
paramValue = productProperties.ElementAt(propertyIndexCompilator).ParamValues.FirstOrDefault(m => m.Param.Name == "Значение, предлагаемое участником");
if (paramValue != null)
{
doc.Tables[1].Cell(i + 4, 6).Range.Text = paramValue.Value;
}
else
{
doc.Tables[1].Cell(i + 4, 6).Range.Text = "";
}
doc.Tables[1].Cell(i + 4, 6).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
// Единица измерения
paramValue = productProperties.ElementAt(propertyIndexCompilator).ParamValues.FirstOrDefault(m => m.Param.Name == "Единица измерения");
if (paramValue != null)
{
doc.Tables[1].Cell(i + 4, 7).Range.Text = paramValue.Value;
}
else
{
doc.Tables[1].Cell(i + 4, 7).Range.Text = "";
}
doc.Tables[1].Cell(i + 4, 7).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
propertyIndexCompilator++;
if (productProperties.Count() == propertyIndexCompilator)
{
propertyIndexCompilator = 0;
productIndexCompilator++;
}
}
}
catch (Exception er)
{
if (doc != null)
doc.Close(ref falseObj, ref missingObj, ref missingObj);
doc = null;
}
application.Visible = true;
return ResultType_enum.Done;
}
catch (Exception ex)
{
doc = null;
message = ex.Message + '\n' + ex.StackTrace;
return ResultType_enum.Error;
}
finally {
isWork = false;
}
}
示例6: OnNewDoc
/// <summary>
/// catches Word's newdocument event
/// just close
/// </summary>
/// <param name="doc"></param>
private void OnNewDoc(Word.Document doc)
{
if (!deactivateevents)
{
deactivateevents = true;
object dummy = null;
doc.Close(ref dummy, ref dummy, ref dummy);
deactivateevents = false;
}
}
示例7: Create
//.........这里部分代码省略.........
doc.Tables[1].Cell(i + 2, 3).Range.Text = paramValue.Value;
}
else
{
doc.Tables[1].Cell(i + 2, 3).Range.Text = "";
}
doc.Tables[1].Cell(i + 2, 3).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
// Минимальные значения показателей
paramValue = productProperties.ElementAt(propertyIndexCompilator).ParamValues.FirstOrDefault(m => m.Param.Name == "Минимальные значения показателей");
if (paramValue != null)
{
doc.Tables[1].Cell(i + 2, 4).Range.Text = paramValue.Value;
}
else
{
doc.Tables[1].Cell(i + 2, 4).Range.Text = "";
}
doc.Tables[1].Cell(i + 2, 4).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
// Максимальные значения показателей
paramValue = productProperties.ElementAt(propertyIndexCompilator).ParamValues.FirstOrDefault(m => m.Param.Name == "Максимальные значения показателей");
if (paramValue != null)
{
doc.Tables[1].Cell(i + 2, 5).Range.Text = paramValue.Value;
}
else
{
doc.Tables[1].Cell(i + 2, 5).Range.Text = "";
}
doc.Tables[1].Cell(i + 2, 5).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
// Значения показателей, которые не могут изменяться
paramValue = productProperties.ElementAt(propertyIndexCompilator).ParamValues.FirstOrDefault(m => m.Param.Name == "Значения показателей, которые не могут изменяться");
if (paramValue != null)
{
doc.Tables[1].Cell(i + 2, 6).Range.Text = paramValue.Value;
}
else
{
doc.Tables[1].Cell(i + 2, 6).Range.Text = "";
}
doc.Tables[1].Cell(i + 2, 6).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
// Конкретные показатели
paramValue = productProperties.ElementAt(propertyIndexCompilator).ParamValues.FirstOrDefault(m => m.Param.Name == "Конкретные показатели");
if (paramValue != null)
{
doc.Tables[1].Cell(i + 2, 7).Range.Text = paramValue.Value;
}
else
{
doc.Tables[1].Cell(i + 2, 7).Range.Text = "";
}
doc.Tables[1].Cell(i + 2, 7).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
// Единица измерения
paramValue = productProperties.ElementAt(propertyIndexCompilator).ParamValues.FirstOrDefault(m => m.Param.Name == "Единица измерения");
if (paramValue != null)
{
doc.Tables[1].Cell(i + 2, 8).Range.Text = paramValue.Value;
}
else
{
doc.Tables[1].Cell(i + 2, 8).Range.Text = "";
}
doc.Tables[1].Cell(i + 2, 8).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
propertyIndexCompilator++;
if (productProperties.Count() == propertyIndexCompilator)
{
propertyIndexCompilator = 0;
productIndexCompilator++;
}
}
}
catch (Exception er)
{
if (doc != null)
doc.Close(ref falseObj, ref missingObj, ref missingObj);
doc = null;
}
application.Visible = true;
return ResultType_enum.Done;
}
catch (Exception ex)
{
doc = null;
message = ex.Message + '\n' + ex.StackTrace;
return ResultType_enum.Error;
}
finally
{
isWork = false;
}
}