不会处理图片对象,只用移动单元格的方法试学着做了一个前移图片的宏,好像可以执行,至于运行速度等就无力考究了,请各位赐教。 Sub movepics() '请首先将光标置于第一个需要前移图片的(空白)单元格。 On Error GoTo exit_1 Application.ScreenUpdating = False Dim n As Integer, Rownum As Integer, Colnum As Byte NP: With Selection '判断光标是否在表格中 If .Information(wdWithInTable) Then '要求插入点所在表格为3列且大于3行,并只选中一个单元格 If .Tables(1).Rows.Count > 3 _ And .Tables(1).Columns.Count = 3 And .Cells.Count = 1 Then Rownum = .Information(wdEndOfRangeRowNumber) Colnum = .Information(wdEndOfRangeColumnNumber) '判断插入点是否在表格最后两行,此处可能有误。 If Rownum + 1 >= .Tables(1).Rows.Count And Colnum = 3 Then Application.ScreenUpdating = True MsgBox "已到表格末尾,共移动了" & n & "次。", vbOKOnly Exit Sub End If '判断插入点是否处于表格第3列 If Colnum Mod 3 <> 0 Then .MoveRight unit:=wdCell, Count:=1 .MoveDown unit:=wdLine, Count:=1, Extend:=wdExtend .Cut .MoveLeft unit:=wdCell, Count:=1 .MoveDown unit:=wdLine, Count:=1, Extend:=wdExtend .Paste .MoveRight unit:=wdCell, Count:=2 Else .MoveDown unit:=wdLine, Count:=2 .MoveLeft unit:=wdCell, Count:=2 .MoveDown unit:=wdLine, Count:=1, Extend:=wdExtend .Cut .MoveUp unit:=wdLine, Count:=2 .MoveRight unit:=wdCell, Count:=2 .MoveDown unit:=wdLine, Count:=1, Extend:=wdExtend .Paste .MoveDown unit:=wdLine, Count:=1 .MoveLeft unit:=wdCell, Count:=2 End If n = n + 1 GoTo NP End If End If End With exit_1: MsgBox "插入点或格式有误!", vbCritical End Sub |