如何通过c#在ms字中插入文本框 [英] How do I insert a textbox in ms word by c#
问题描述
hellow
i我试图通过c#在word文档中插入一个文本框,我使用这段代码
hellow
i am trying to insert a textbox in word document by c# , i use this code
//rng = oDataDoc.Tables[1].Cell(1, 1).Range;
//wrdApp.ActiveDocument.Shapes.AddTextbox(??,1, 1, 200, 200, ref rng);
i在第一个和最后一个参数中有问题。
a对microsoft.office.interop.word的引用已添加到我的项目
关于它应该是第一个参数
Microsoft.office.Core.MsoTextOrientation
但我无法定义我的程序中的这个变量
i可以编写
Microsoft.Office.Interop.Word。
在上面一行的最后一个点之后我不知道哪一个shuold我选择
来自列表框由ms visual studio给出
i需要解释第一个和最后一个参数
i have problem in 1st and last parameter.
a reference to microsoft.office.interop.word already added to my project
in regard to the first parameter it should be
Microsoft.office.Core.MsoTextOrientation
but i could not define this variable in my program
i could write
Microsoft.Office.Interop.Word.
after the last dot in the above line i do not know which one shuold i select
from the listbox being given by the ms visual studio
i need explanation for the 1st and last parameter
推荐答案
看看这里:
Shapes.AddTextbox方法 [ ^ ]
第一个参数: MsoTextOrientation枚举 [ ^ ]
最后一个参数:范围界面 [ ^ ]
下面的代码应该有效:
Have a look here:
Shapes.AddTextbox method[^]
first parameter: MsoTextOrientation enumeration[^]
last parameter: Range interface[^]
Below code should works:
Range rng = oDataDoc.Tables[1].Cell(1,1).Range;
Shape sh = oDataDoc.Shapes.AddTextBox(Microsotft.Office.Core.msoTextOrientationHorizontal, 1, 1, 200, 200, ref rng);
Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal
位于OFFICE .COM NOT OFFICE.NET
这个作品
Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal
is located in OFFICE .COM NOT OFFICE.NET
THIS WORKS
rng = oDataDoc.Tables[1].Cell(1, 1).Range;
xShape = oDataDoc.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, 1, 1, 200, 200, ref rng);
这篇关于如何通过c#在ms字中插入文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!