VBA - Alternative to Copy & Paste?

T

Tom Johnsen

Hi!

Does anyone know about possible alternatives to Copy &
Paste when using Visual Basic for Applications?

I have a large document with text/phrases which I call
TextBank. When I am going to get text from this textbank
and use it in another document, I does not want to use
for example "Selection.Copy" and "Selection.Paste".

Is there any alternatives to this or do I have to use for
example XML instead?
 
P

Peter Hewett

Hi Tom Johnsen

You need to set up 2 Range objects. One mapping the text you want to copy (from your
TextBank document) and the other mapping the location in the document where you want the
text inserted.

This is how you do it:

Public Sub MergeSubDocuments()
Dim rngSource As Word.Range
Dim rngDestination As Word.Range

' Set up rngSource and rngDestination here
'Set rngSource =
'Set rngDestination =

' Copy the text from source to destination
rngDestination.FormattedText = rngSource.FormattedText
End Sub

HTH + Cheers - Peter
 
G

Guest

Thank you very much for your help!

This was exactly the code I was missing. 10 points to
you! :)

Regards Tom Johnsen
-----Original Message-----
Hi Tom Johnsen

You need to set up 2 Range objects. One mapping the
text you want to copy (from your
TextBank document) and the other mapping the location in
the document where you want the
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top