以下是引用c81在2006-11-2 14:02:17的发言:好象窗口替换不行了, 要编写个小vba才成。 ======== 我这样写为什么不行呢? Sub k1() Dim tb As Table Dim myString As String For Each tb In ActiveDocument.Tables myString = tb.Cell(2, 1).Range.Text If myString = "组长意见" Then tb.Cell(2, 2).Range.Text = "同意" End If Next End Sub
'* +++++++++++++++++++++++++++++ '* Created By SHOUROU@ExcelHome 2006-11-3 6:07:29 '仅测试于System: Windows NT Word: 11.0 Language: 2052 '№ 0093^The Code CopyIn [ThisDocument-ThisDocument]^' '* ----------------------------- Option Explicit
Sub Example() Dim oTable As Table, myRow As Row Application.ScreenUpdating = False '关闭屏幕更新 With ActiveDocument For Each oTable In .Tables Set myRow = oTable.Rows.Last '指定目标行 myRow.Cells(1).Range.Text = "组长意见" myRow.Cells(2).Range.Text = "同意" Next End With Application.ScreenUpdating = True '恢复屏幕更新 End Sub '---------------------- Sub k1() Dim tb As Table Dim myString As String For Each tb In ActiveDocument.Tables myString = tb.Cell(2, 1).Range.Text myString = VBA.Mid(myString, 1, Len(myString) - 2) '去除单元格结束标记和竖线分隔符 If myString = "组长意见" Then tb.Cell(2, 2).Range.Text = "同意" End If Next End Sub '---------------------- TO C81,请参考: http://club.excelhome.net/dispbbs.asp?boardid=23&replyid=547819&id=192527&page=1&skin=0&Star=2第13楼。 |