Storing a range into a variable

  • Thread starter Thread starter crsmit
  • Start date Start date
C

crsmit

Hi guys,

I'm struggling with something I just cannot understand.

I have several different ranges that I need to store into variables.
I have created an array of ranges
dim rng(3) as range

later in my code I would do the following
rng(1) = selection.range.duplicate

But when i change the text on my document, it changes it in all th
variables.

Why is this? How can I copy a range into a variable, modify my documen
and then paste the original variable back to the document?

email me at (e-mail address removed)

Thanx
Richar
 
Hi Crsmit,

Note that this is an end-user newsgroup; you'd have gotten a faster
response posting to a word.vba group...

The thing is, you're saving the RANGE (the position in the document), so
if you change the text in the range that's what you'll get when you query
or use the range in any way.

What you apparently need to do is save the TEXT in a variable. Or, if
you're concerned about retaining formatting and such, you'll have to save
the ranges in another file, or possibly as AutoText entries. There is no
way to save the FORMMATED CONTENT of a range in a variable.
I'm struggling with something I just cannot understand.

I have several different ranges that I need to store into variables.
I have created an array of ranges
dim rng(3) as range

later in my code I would do the following
rng(1) = selection.range.duplicate

But when i change the text on my document, it changes it in all the
variables.

Why is this? How can I copy a range into a variable, modify my document
and then paste the original variable back to the document?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)
 
Back
Top