這一句代碼
newdoc.Range(newdoc.Range.End - 1, newdoc.Range.End - 1).Paste
一直顯示無效
但是逐陳述句除錯是可以運行的
Dim newdoc As Document, sredoc As Document, mytable As Table, rng As Range
Set newdoc = Documents.Add
Set sredoc = ThisDocument
For Each mytable In sredoc.Tables
Set rng = mytable.Range
rng.Copy
newdoc.Range(newdoc.Range.End - 1, newdoc.Range.End - 1).InsertParagraph
newdoc.Range(newdoc.Range.End - 1, newdoc.Range.End - 1).Paste
Next mytable
newdoc.SaveAs "E:\VBA\資料\word-VBA操作\新表收集"
Next mytable
newdoc.SaveAs "E:\VBA\資料\word-VBA操作\新表收集"
End Sub
uj5u.com熱心網友回復:
Paste呼叫前加一句:DoEvents
不行的話,回圈中的每條陳述句間都插入DoEvents;
uj5u.com熱心網友回復:
我試了一下,我這邊測驗是沒有問題的uj5u.com熱心網友回復:
嗯嗯謝謝好了,請問這句話在這里的作用是什么
uj5u.com熱心網友回復:
顧名思義,處理事件;這條陳述句讓程式等待復制粘貼等其他操作執行完畢后,再繼續后邊陳述句的執行;
uj5u.com熱心網友回復:
學習了,謝謝~轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/26864.html
標籤:VBA
