473,409 Members | 2,063 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

Make a copy of a Word Range object

Is there any way to make a copy of a word.range object? I have a range in a
document and I need to monkey around with it but I don't want to change the
original in the document. I've tried Duplicate() and assigning it to a new
variable. But if I change the stuff in the new variable, it changes the
original also.

So what I need is a new copy of the variable - not pointing to the same
thing.

TIA - Jeffrey
Nov 20 '05 #1
1 6707
What exactly do you mean by "changing stuff"? As I understand it,
Duplicatae() returns a clone of the original range object.

If you modify the the text or formatting properties of the original range,
however, the duplicated range will also show the same change -- because the
change to the first range is actually changing the underlying Word document.
For example in this air code,

Dim FirstRange as Word.Range = Word.Selection.Range
Dim SecondRange as Word.Range = FirstRange.Duplicate()
FirstRange.Text = "New text"

the text of SecondRange will also be changed to "New text" because the
underlying Word document has changed. The two range objects are merely
"pointers" (of sorts) for the content in the Word document itself.

However, if you make a change to a range that doesn't modify the document,
it should only affect that particular range object. For example, if you
have the line "FirstRange.Length = 0" it shouldn't change the length of
SecondRange.

Is this your issue, or is there something else? Perhaps you could post a
sample of code that illustrates your problem.

"Jeffrey Bradshaw" <Je**************@Dictaphone.comNOSPAM> wrote in message
news:eh**************@tk2msftngp13.phx.gbl...
Is there any way to make a copy of a word.range object? I have a range in a document and I need to monkey around with it but I don't want to change the original in the document. I've tried Duplicate() and assigning it to a new
variable. But if I change the stuff in the new variable, it changes the
original also.

So what I need is a new copy of the variable - not pointing to the same
thing.

TIA - Jeffrey

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Bob | last post by:
Here's what I have: void miniVector<T>::insertOrder(miniVector<T>& v,const T& item) { int i, j; T target; vSize += 1; T newVector; newVector=new T;
2
by: Ruslan Shlain | last post by:
Hello everyone. I have a question that I tried to find an answer over the weekend but did not succeeded. I have a Word template with a couple of "tags" ( <<My Tag>>) that I need to replace with...
0
by: jijo kuruvila | last post by:
I am having one grid..i want to export that grid to word..after doing only two fields r coming ie serial no: and total..product name, quantity and unitcost r not coming into the word...those three...
6
by: Yuri Vanzine | last post by:
In asp we can run VBSCRIPT client-side which allows for 'easy' :?) ms office COM object instantiation. How do I access a Word object in ASP.NET on the client side? I would like to do spell...
5
by: STeve | last post by:
Hey guys, I currently have a 100 page word document filled with various "articles". These articles are delimited by the Style of the text (IE. Heading 1 for the various titles) These articles...
2
by: Al_P via DotNetMonster.com | last post by:
I have: Win2K Office2000 Working in VB.Net (2003) My .Net project has a reference to Word 9.0 Instantiating things in a simple and straightforward manner: Dim word as Word.Application Dim...
2
by: Alan T | last post by:
I have two bookmarks, eg. beginMark and endMark I need to get the text between these 2 bookmarks, how do I do that? eg. <beginMark> Hello Word! This is Saturday.
1
by: Darsin | last post by:
What i am doing is to pull the data from a CMS and import it to Word 2007 Beta and i also have to export the data from Word 2007 Beta back to that CMS. We have with us two Web Services of the CMS....
0
by: deboe | last post by:
I am trying to pull in some data from a database (Access) and merge the data to a Word document (basically mail merge). I got the data to fill in the bookmarks in the document but only the first...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.