word合并单元格后,VBA读取设置相应单元格内容
2008-11-02 16:29
316 查看
'设置单元格的行列坐标并写的word文档中
Sub SetTablePosition()
Dim tbl As Table
Dim cell As cell
Dim tblIndex As Integer
Dim cellContent As String
'以下遍历表格中存在的单元格
For Each tbl In ThisDocument.Tables
tblIndex = tblIndex + 1
Row = 1
col = 1
Do While (1)
Set cell = tbl.cell(Row, col)
If Not cell Is Nothing Then '如果单元格存在
Debug.Print cell.RowIndex
Debug.Print cell.ColumnIndex
'TO-DO**********************************************************************
cell.Select
cellContent = Selection.Text
'If Len(Trim(content)) <> 0 Then GoTo nextCell
Selection.Text = "p" & Selection.Information(wdActiveEndPageNumber) _
& "t" & tblIndex & "r" & Row & "c" & col
'END**********************************************************************
Set cell = tbl.cell(cell.RowIndex, cell.ColumnIndex).Next
If cell Is Nothing Then Exit Do
cell.Select
Row = cell.RowIndex
col = cell.ColumnIndex
Set cell = tbl.cell(Row, col)
Else
Exit Do
End If
nextCell: Loop
Next
End Sub
相关文章推荐
- VBA 设置单元格内容
- 对剪贴板的内容的进行读取和设置
- 配置文件,就是项目启动时候会读取这个配置文件,设置相应启动参数
- POI设置单元格内容下拉框选择和单元格提示功能
- gridview如何改变行显示的内容以及设置单元格的是否允许编辑
- VBA读取可选择文件夹下可选择txt文件内容
- 如何动态设置全局theme,及在web.config中读取pages节点的内容。
- Excel设置下拉菜单并隐藏下拉菜单来源单元格内容
- 关于C# wpf DataGrid单元格双击设置单元格内容
- VBA 统计合并后的单元格内容方法
- POI读取excel某个单元格内容
- 2.6.2 用NPOI操作EXCEL--设置密码才可以修改单元格内容
- 程序读取Excel,单元格内容超过255被截断解决方法
- 一个Excel里用的VBA,循环处理每个单元格,将分号分隔的内容倒过来
- VBA设置单元格格式
- EXCEL-VBA:设置单元格格式
- C#设置DataGridView某一具体单元格的内容居中显示
- css设置强制单元格内容自动/不自动换行
- ABAP--一个读取EXCEL单元格的内容超过256个字符的代码样例(from Jack)
- Spring读取外部的.properties文件内容并设置给bean的两种方法