谢谢蓝总!十分感谢!大师果然是大师!但是CurrentTable.EditCopy()和syscmd.Edit.copy()只能复制表头的字段名(英文),不能复制标题(中文),
后面自己想了个土办法,遍历所选区域的表头和数据,组装到str这个字符串变量,再装进ClipBoard,
土办法比较麻烦,请问蓝老师,想要复制表头的标题行,请问有没有什么自带的简单方法呢:
Dim S As String
If CurrentTable.LeftCol >=0 And CurrentTable.RightCol >=0 Then
For i As Integer = CurrentTable.LeftCol To CurrentTable.RightCol
Dim c As Col=CurrentTable.Cols(i)
If i=CurrentTable.RightCol Then
s=s & c.Caption & chr(13)
Else
s=s & c.Caption & chr(9)
End If
Next
End If
If CurrentTable.TopPosition >=0 And CurrentTable.BottomPosition>=0 Then
For i As Integer =CurrentTable.TopPosition To CurrentTable.BottomPosition
Dim R As Row =CurrentTable.Rows(i)
If CurrentTable.LeftCol >=0 And CurrentTable.RightCol >=0 Then
For j As Integer = CurrentTable.LeftCol To CurrentTable.RightCol
Dim a As String
a=CurrentTable.Rows(i)(j)
If j=CurrentTable.RightCol Then
s=s & a & chr(13)
Else
s=s & a & chr(9)
End If
Next
End If
Next
End If
ClipBoard.SetText(s)
[此贴子已经被作者于2024/10/19 14:50:35编辑过]