将 VBA 2-Dim 字符串数组粘贴到 Word 表中
我有一个表的抽象,其中包含 Word VBA 中的二维字符串数组。
现在我想将此数组保存到 Word 文档中的表中,而不需要遍历两个维度...据我所知,有一种方法可以从 excel 中获取 Range(...) 内容作为数组...
例如:
Dim rng As Excel.Range
Set rng = excelTabelle.Range("A4:F" + CStr(lastRow))
arrData = rng.Value
是否有将其粘贴到 Word 表格中的类似解决方案?
迭代需要太多的执行时间,所以我正在寻找一种更有效的方法来做到这一点。
问候,波斯克伦
I have an abstraction of a table hold als a two dimensional String array in Word VBA.
Now I want to save this array into a table in a word document, without iteration through both dimensions...afaik there is a method to get a Range(...) content from excel as array...
e.g.:
Dim rng As Excel.Range
Set rng = excelTabelle.Range("A4:F" + CStr(lastRow))
arrData = rng.Value
is there a similar solution for pasting this into a Word table?
Iterating needs too much time for the execution, so I'm looking for a more efficient way to do that.
Greets, poeschlorn
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种解决方案可能是利用剪贴板来满足您的需求。它不像 Excel 那样容易,但对您来说可能足够快了。下面是一些示例代码,说明如何通过剪贴板将一些文本放入 2x3 字表中(将 Microsoft Forms 2.0 对象库的引用添加到您的 VBA 文档中):
我建议您对其进行调整,将任意二维数组放入字符串并以类似的方式粘贴。如果您需要更多帮助,请回来给我们提供更多详细信息。
One solution may be to utilize the clipboard for your needs. It is not so easy as in Excel, but perhaps fast enough for you. Here is some sample code how to get some text through the clipboard into a 2x3 word table (add a reference to Microsoft Forms 2.0 object library to your VBA doc):
I suggest that you adapt this to put an arbitrary 2-dimensional array into a string and paste it in a similar manner. If you need more help, come back give us more details, please.