1,隨便打開一個word文檔。
2,按下Alt + F11 VBA編輯器,在左側的「工程資源管理器」窗口中找到Normal 項目,右鍵選擇插入->模塊。

彈出一下彈窗

3,輸入一下代碼

代碼:
Sub RemoveEmptyTableRows()Dim tbl As TableDim row As RowDim cell As CellDim i As LongFor Each tbl In ActiveDocument.Tables' 從最后一行向前遍歷,避免刪除導致索引變化For i = tbl.Rows.Count To 1 Step -1Set row = tbl.Rows(i)Dim isEmptyRow As BooleanisEmptyRow = TrueFor Each cell In row.Cells' 去除單元格中的控制字符并檢查是否為空Dim cellText As StringcellText = Replace(Replace(cell.Range.Text, Chr(13), ""), Chr(7), "")If Trim(cellText) <> "" ThenisEmptyRow = FalseExit ForEnd IfNext cellIf isEmptyRow Thenrow.DeleteEnd IfNext iNext tblMsgBox "處理完成!"
End Sub
Ctrl+S保存一下
然后就可以關掉這個窗口,在回到word界面

4,返回Word界面,按下 Alt + F8,選擇RemoveEmptyTableRows,再點擊運行,即可完成空白行的批處理。

運行結果
