Home > Software engineering >  Take the form to the new document in the word
Take the form to the new document in the word

Time:11-17

This code

Newdoc. Range (newdoc. Range. End - 1, newdoc. Range. The End - 1). Paste

Always show invalid

But by the statement debugging can be run


Dim newdoc As Document, sredoc As Document, mytable As Table, RNG As Range

The Set newdoc=Documents. The Add



The Set sredoc=ThisDocument



For Each mytable In sredoc. Tables

The Set of RNG=mytable. Range
RNG. Copy



Newdoc. Range (newdoc. Range. End - 1, newdoc. Range. The End - 1). The InsertParagraph


Newdoc. Range (newdoc. Range. End - 1, newdoc. Range. The End - 1). Paste


Next mytable

Newdoc. SaveAs "E: \ VBA \ data \ word - VBA operation \ new table collection"















Next mytable

Newdoc. SaveAs "E: \ VBA \ data \ word - VBA operation \ new table collection"











End Sub

CodePudding user response:

Paste before invoking add:
DoEvents

If not, in the loop is inserted between each statement DoEvents;

CodePudding user response:

I tried it on and test on my side is no problem

CodePudding user response:

reference 1st floor milaoshu1020 response:
Paste before invoking add:
DoEvents

If not, in the loop is inserted between each statement DoEvents;

Yeah yeah thanks ok, could you tell me what is the function of this sentence here

CodePudding user response:

As the name implies, handle events;
This statement makes program after waiting for the copy and paste, and other operations has been completed, continue to back the execution of the statement;

CodePudding user response:

Learning, thank you ~
  •  Tags:  
  • VBA
  • Related