作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我知道以前有人问过这个问题,但我只能找到在您传输数据时在 Word 中创建表格的网站。
我有一个包含 3 个表格的 Word 文档,并希望从客户端发送的 Excel 文件中提取数据到 Word 表格中的某些单元格中。
例如,我想将 Excel 中单元格 D3 的内容放入 Word 第二个表格中的单元格 2,2 中?有没有办法引用哪个表来插入数据?
任何人都可以帮助解决这个问题,或者只是将我推向正确的方向,因为我对宏等比较陌生。当我们使用 Word 文档并将 Excel 文件发送给我们时,在 Word 中制作宏是否更有益?
谢谢
最佳答案
我已经设法修复它,通常它相对简单,但感谢@David Zemens 朝着正确的方向插入。我不知道我以前在“ThisDocument”中搜索时是如何错过“Tables”的。
Sub GetData()
Dim objExcel As New Excel.Application
Dim exWb As Excel.Workbook
Dim ExcelFileName As String
ExcelFileName = "{Put the directory of Excel file here}"
Set exWb = objExcel.Workbooks.Open(ExcelFileName)
'Set the text of the cell from Excel to the cell in the specified table in Word (the second table in this instance)
ActiveDocument.Tables(2).Cell(2, 2).Range.Text = exWb.Sheets("Test").Cells(2, 1)
' Close Excel bits
exWb.Close
Set exWb = Nothing
End Sub
关于vba - 从 Excel 中获取数据并插入到预先存在的 Word 表中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23805804/
问了这个问题How to reach CSS zen? ,我现在明白我遇到的问题大多与定位有关。我发现一些文章说 CSS 作为布局系统并不总是足够好。 http://echochamber.me/vi
我是一名优秀的程序员,十分优秀!