关于word操作里的SaveAs
大家先看一下我的代码using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Reflection;
namespace TryTemp1
{
class WordAPI
{
private Microsoft.Office.Interop.Word.Application wordApp;
private Microsoft.Office.Interop.Word.Document _wordDocument;
private object defaultV = System.Reflection.Missing.Value;
private object documentType;
public WordAPI()
{
wordApp = new Microsoft.Office.Interop.Word.Application();
documentType = Microsoft.Office.Interop.Word.WdDocumentType.wdTypeDocument;
_wordDocument = wordApp.Documents.Add(ref defaultV, ref defaultV, ref documentType, ref defaultV);
}
public void EndWd(string dePath)
{
_wordDocument.SaveAs(ref dePath, ref defaultV,ref defaultV, ref defaultV, ref defaultV, ref defaultV, ref defaultV, ref defaultV, ref defaultV, ref defaultV, ref defaultV, ref defaultV, ref defaultV, ref defaultV, ref defaultV, ref defaultV);
_wordDocument.Close(ref defaultV, ref defaultV, ref defaultV);
wordApp.Application.Quit(ref defaultV, ref defaultV, ref defaultV);
}
//public void SaveAsWord()
//{
// object doNoteSaveChange = Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges;
//}
}
}
报错:
错误 1 与“Microsoft.Office.Interop.Word._Document.SaveAs(ref object, ref object, ref object, ref object, ref object, ref object, ref object, ref object, ref object, ref object, ref object, ref object, ref object, ref object, ref object, ref object)”最匹配的重载方法具有一些无效参数 C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\TryTemp1\TryTemp1\WordAPI.cs 25 13 TryTemp1
错误 2 参数“1”: 无法从“ref string”转换为“ref object” C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\TryTemp1\TryTemp1\WordAPI.cs 25 38 TryTemp1
警告 3 方法“Microsoft.Office.Interop.Word._Document.Close(ref object, ref object, ref object)”和非方法“Microsoft.Office.Interop.Word.DocumentEvents2_Event.Close”之间存在二义性。将使用方法组。 C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\TryTemp1\TryTemp1\WordAPI.cs 26 27 TryTemp1
警告 4 方法“Microsoft.Office.Interop.Word._Application.Quit(ref object, ref object, ref object)”和非方法“Microsoft.Office.Interop.Word.ApplicationEvents4_Event.Quit”之间存在二义性。将使用方法组。 C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\TryTemp1\TryTemp1\WordAPI.cs 27 33 TryTemp1
错误 5 “System.Windows.Forms.TextBox”是一个“类型”,这在给定的上下文中无效 C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\TryTemp1\TryTemp1\Program.cs 19 91 TryTemp1
--------------------编程问答--------------------
补充:.NET技术 , C#