使用Microsoft.Office.Interop.Word向word文档中插入图形,并且修改图形形态时,在执行到
object a = shape.Adjustments.Count;这句话时发生错误[System.InvalidCastException]环境windows 2003
office 2003使用dllPIA--->Office.dll Version 11.0.0.0PIA--->Microsoft.Office.Interop.Word Version 11.0.0.0
详细代码如下
try
{
object missing = System.Reflection.Missing.Value;
Word.Application WordApp = new Word.Application();
WordApp.Visible = true;
Word.Document WordDoc = new Word.Document();
Word.Selection se;
WordDoc = WordApp.Documents.Add(ref missing, ref missing, ref missing, ref missing);
Word.Shape shape = WordDoc.Shapes.AddShape(30
, 100f
, 100f
, 200f
, 100f
,ref missing);
se = WordApp.Selection;
shape.Select(ref missing);
shape.Width = 400;
object a = shape.Adjustments.Count;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
object a = shape.Adjustments.Count;这句话时发生错误[System.InvalidCastException]环境windows 2003
office 2003使用dllPIA--->Office.dll Version 11.0.0.0PIA--->Microsoft.Office.Interop.Word Version 11.0.0.0
详细代码如下
try
{
object missing = System.Reflection.Missing.Value;
Word.Application WordApp = new Word.Application();
WordApp.Visible = true;
Word.Document WordDoc = new Word.Document();
Word.Selection se;
WordDoc = WordApp.Documents.Add(ref missing, ref missing, ref missing, ref missing);
Word.Shape shape = WordDoc.Shapes.AddShape(30
, 100f
, 100f
, 200f
, 100f
,ref missing);
se = WordApp.Selection;
shape.Select(ref missing);
shape.Width = 400;
object a = shape.Adjustments.Count;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
object a = shape.Adjustments.Count;object 是C#基础数据类型,shape.Adjustments.Count 是Word命名空间下的数据 ,不能转换