如何将cusotucontrol添加到word文档[C#Word addin] [英] How to add a cusotucontrol to word document [ C# Word addin ]
问题描述
我在打印代金券上添加了一个单词。它包含一个名为BarcodeWithZXing的自定义控件。 BarcodeWithZXing由C#编写并构建到Dll文件。 addin对此的引用。
问题是:
如何将BarcodeWithZXing添加到文档中。我尝试了方法doc.shapes.addolecontrol,但我不知道BarcodeWithZXing的classType。
有什么方法可以完成我的想法吗?谢谢!
顺便说一下,我使用微软访问条码9.0来做VBA。但重新打开文件后工作效果不佳。
如何将cusotucontrol添加到word文档[C#Word addin ]在MSDN上 [ ^ ]
I make a word addin to print vouchers. that contains a custom control called BarcodeWithZXing. the BarcodeWithZXing is written by C# and build to a Dll file. the addin reference to that.
the question is :
how to add the BarcodeWithZXing to document. I try the method "doc.shapes.addolecontrol ", but I didn't know the classType of BarcodeWithZXing.
Is there any method to finish my idea? thanks !
by the way, I was use the Microsoft access barcode 9.0 to do by VBA. but that work is not good after reopen the file.
How to add a cusotucontrol to word document [ C# Word addin ] on MSDN [^]
推荐答案
您没有提供足够的信息。然而......
请参考:在运行时向Office文档添加控件 [ ^ ]
You did not provide enough information. Nevertheless...
Please, refer this: Adding Controls to Office Documents at Run Time[^]
您可以使用:
var newContentControl = currentRange.ContentControls.Add();
newContentControl .SetPlaceholderText(null,null,Empty);
newContentControl.Title = elementType.ToString();
你必须设置范围到您要插入内容控件的位置,或使用WordApplication.Selection.Range获取当前范围。
You can use:
var newContentControl = currentRange.ContentControls.Add();
newContentControl.SetPlaceholderText(null, null, "Empty");
newContentControl.Title = elementType.ToString();
You must set the range to the location where you want to insert the content control or use WordApplication.Selection.Range to get the current range.
这篇关于如何将cusotucontrol添加到word文档[C#Word addin]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!