Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# word interop中的Application.InchesToPoints不';t工作_C#_.net_Ms Word_Interop - Fatal编程技术网

C# word interop中的Application.InchesToPoints不';t工作

C# word interop中的Application.InchesToPoints不';t工作,c#,.net,ms-word,interop,C#,.net,Ms Word,Interop,在我的应用程序中,我使用 using Word = Microsoft.Office.Interop.Word; 现在我需要把我的表格列宽改为3厘米,因为我知道标准方法使用的是点而不是厘米或英寸,所以我想把它转换成点。正如我在MSDN中所读到的,在切点()中必须有函数 但是当我使用这个代码时 wordtable.Columns[0].Width = Application.InchesToPoints(3f / 2.54f); 有一个例外: 错误1“System.Windows.Forms.

在我的应用程序中,我使用

using Word = Microsoft.Office.Interop.Word;
现在我需要把我的表格列宽改为3厘米,因为我知道标准方法使用的是点而不是厘米或英寸,所以我想把它转换成点。正如我在MSDN中所读到的,在切点()中必须有函数

但是当我使用这个代码时

wordtable.Columns[0].Width = Application.InchesToPoints(3f / 2.54f);
有一个例外:

错误1“System.Windows.Forms.Application”不包含 定义 “InchesToPoints”Z:\porn\WindowsFormsApplication3\Form1.cs 194 62 WindowsFormsApplication3


我该怎么办?

应用程序
指VBA中的托管应用程序


从外部,您需要使用
word.InchesToPoints
(其中
word
是word实例变量)。

应用程序
指VBA中的宿主应用程序


从外部您需要使用
word.InchesToPoints
(其中
word
是word实例变量)。

是的,但我无法创建实例变量,因为“Microsoft.Office.Interop.word”是一个“名称空间”,但像“类型”一样使用。这一个在代码之后返回我:`word word=new word()`你似乎在不理解它是什么的情况下使用它。那就别用了
var word=new Microsoft.Office.Interop.word.Application()
.Yeap,但我无法创建实例变量,因为`'Microsoft.Office.Interop.Word'是一个“名称空间”,但像“类型”一样使用``这一个在以下代码之后返回我:`Word Word=new Word()`你似乎在不理解它是什么的情况下使用它。那就别用了
var word=new Microsoft.Office.Interop.word.Application()