View Single Post
 
Old 12-07-2015, 05:08 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

That's not how a macro would normally work and making one do so would greatly complicate things.

Whether you're running the macro from Excel or Word, the process is much the same. Since the range is known, the macro might simply copy the contents of cells A1:A300 and D1300 to cells A1:A300 & B1:B300, respectively, of a designated Word table, omitting the unwanted rows.

The Word table might be designated by its index in the document (e.g. the 3rd table), but only if it will always be the 3rd table, or via a bookmark or some other unique indicator. Similarly the source worksheet might be identified by its name or position in the workbook.

You refer to activating the document; that isn't necessary. Using an Excel macro, provided the document is open, the data can be transferred without activating or selecting anything in it. If it's a known document that's closed, the macro can even open it - or create a new one from an appropriate template. Neither is activating the worksheet or selecting anything if the source range is known beforehand. Likewise, a Word macro can extract the data from either an open workbook or a closed one. However, it makes a significant difference as to how the macro is coded if you're running the macro from Excel or from Word. You need to say which you want to do.

Hence, there's no need for any manual processes; providing for them actually makes the coding far more complicated, since one has to suspend (not terminate) the macro's execution while the manual processes are done.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote