using Microsoft.Office.Interop.Word;
                wordDoc.Tables.Add(rng2, 14, 6, ref missingValue, ref missingValue);
                wordDoc.Tables.Item(1).Rows.HeightRule = Word.WdRowHeightRule.wdRowHeightAtLeast;
                wordDoc.Tables.Item(1).Rows.Height = wordApp.CentimetersToPoints(float.Parse("0.8"));
                wordDoc.Tables.Item(1).Range.Font.Size = 10;
                wordDoc.Tables.Item(1).Range.Font.Name = "宋体";错误 1 “Microsoft.Office.Interop.Word.Tables”不包含“Item”的定义,并且找不到可接受类型为“Microsoft.Office.Interop.Word.Tables”的第一个参数的扩展方法“Item”(是否缺少 using 指令或程序集引用?) H:\TM\08\PWMS\PWMS\PerForm\F_ManFile.cs 846 32 PWMS
请问:我在网上搜索了一下,找不到正确答案。有哪位大侠指点一下?在此多谢了。虽然分不多,但心诚啊。

解决方案 »

  1.   

    是不是版本没对,你引用的那个没Item
    填加引用:Microsoft Office 11.0 Object Library 
    把Tables.Item(1)改成Tables[1]。
      

  2.   

    http://topic.csdn.net/u/20120319/10/b1bd2f65-1414-40d9-8fac-29473cf77878.html
      

  3.   

    或者直接去掉Item试试
    wordDoc.Tables.Range.Font.Size = 10;
      

  4.   

    无需安装office、脱离office、 操作officeTX Text Control .NET是完全的免最终用户版权使用费(royalty-free)的文字处理控件(类似于Word的功能),在控件中为开发者提供了大量的文字处理特性
      

  5.   

    我只是举个例而已,你要找里面的,肯定有Range
      

  6.   

    问题解决了。
    该代码是针对word9.0(office2000)的,而本计算机安装的是word12.0(office2007),所以出错。下面贴出word12.0代码。wordDoc.Range(ref start, ref end).InsertBefore(strInfo);    //插入文本
    wordDoc.Range(ref start, ref end).Font.Name = "Verdana";    //设置字体
    wordDoc.Range(ref start, ref end).Font.Size = 20;   //设置字体大小
    wordDoc.Range(ref start, ref end).ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter; //设置字体居中另外,如果提示word与microsoft.office.interop.word冲突,忽略word。那是因为word版本是word9.0,而引用的microsoft.office.interop.word的版本是word12.0。解决办法:将word从引用中删除即可。