Same text in cells

S

Sol Apache

I am doing a business card template so most text repeats itself. The back
side of the card template has 8 cells with exactly the same text to be
entered. At the moment I am repeating each code of text for each cell, just
changing the cell reference. This works but it is slow.

Is there a quicker way of referring to the repeated data just once and
having it placed into each cell.

Thanks for any help


Sol
 
J

Jean-Guy Marcil

Sol Apache was telling us:
Sol Apache nous racontait que :
I am doing a business card template so most text repeats itself. The
back side of the card template has 8 cells with exactly the same text
to be entered. At the moment I am repeating each code of text for
each cell, just changing the cell reference. This works but it is
slow.

Is there a quicker way of referring to the repeated data just once and
having it placed into each cell.

Show us your code.

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
S

Sol Apache

Hi Jean-Guy
Here is my code. It repeats another seven times, going to a different table
cell.

Thanks for any help.


Dim myRg as range
Set myRg = _
ActiveDocument.Tables(2).Cell(Row:=4, Column:=2).Range

With myRg
..Delete
.Text = TxtAlt1Title1.Value & Chr(13)
.Style = ("TitleAddressWhite")
.Collapse wdCollapseEnd
.Text = TxtAlt1Addr1 & Chr(13)
.Style = ("BaseAddress Back")
.Collapse wdCollapseEnd
.Text = TxtAlt1Addr2.Value & Chr(13)
.Style = ("BaseAddress Back")
..Collapse wdCollapseEnd
..Text = TxtAlt1Addr3.Value & Chr(13)
.Style = ("BaseAddress Back")
.Collapse wdCollapseEnd
.Text = "Telephone: +" & TxtAlt1Phone & Chr(13)
.Style = ("DirectLine Back")
.Collapse wdCollapseEnd
.Text = "Facsimile: +" & TxtAlt1Fax.Value & Chr(13) & Chr(13)
.Style = ("BaseAddress Back")
..Collapse wdCollapseEnd

..Text = txtAlt2Title1.Value & Chr(13)
.Style = ("TitleAddressWhite")
.Collapse wdCollapseEnd
.Text = TxtAlt2Addr1 & Chr(13)
.Style = ("BaseAddress Back")
.Collapse wdCollapseEnd
.Text = TxtAlt2Addr2.Value & Chr(13)
.Style = ("BaseAddress Back")
..Collapse wdCollapseEnd
..Text = TxtAlt2Addr3.Value & Chr(13)
.Style = ("BaseAddress Back")
.Collapse wdCollapseEnd
.Text = "Telephone: +" & TxtAlt2Phone & Chr(13)
.Style = ("DirectLine Back")
.Collapse wdCollapseEnd
.Text = "Facsimile: +" & TxtAlt2Fax.Value & Chr(13) & Chr(13)
.Style = ("BaseAddress Back")
..Collapse wdCollapseEnd

..Text = TxtAlt3Title1.Value & Chr(13)
.Style = ("TitleAddressWhite")
.Collapse wdCollapseEnd
.Text = TxtAlt3Addr1 & Chr(13)
.Style = ("BaseAddress Back")
.Collapse wdCollapseEnd
.Text = TxtAlt3Addr2.Value & Chr(13)
.Style = ("BaseAddress Back")
..Collapse wdCollapseEnd
..Text = TxtAlt3Addr3.Value & Chr(13)
.Style = ("BaseAddress Back")
.Collapse wdCollapseEnd
.Text = "Telephone: +" & TxtAlt3Phone & Chr(13)
.Style = ("DirectLine Back")
.Collapse wdCollapseEnd
.Text = "Facsimile: +" & TxtAlt3Fax.Value & Chr(13)
.Style = ("BaseAddress Back")
..Collapse wdCollapseEnd
End With
 
J

Jean-Guy Marcil

Sol Apache was telling us:
Sol Apache nous racontait que :
Hi Jean-Guy
Here is my code. It repeats another seven times, going to a different
table cell.

Thanks for any help.


Dim myRg as range
Set myRg = _
ActiveDocument.Tables(2).Cell(Row:=4, Column:=2).Range

With myRg
.Delete
.Text = TxtAlt1Title1.Value & Chr(13)
.Style = ("TitleAddressWhite")
.Collapse wdCollapseEnd
.Text = TxtAlt1Addr1 & Chr(13)
.Style = ("BaseAddress Back")
.Collapse wdCollapseEnd
.Text = TxtAlt1Addr2.Value & Chr(13)
.Style = ("BaseAddress Back")
.Collapse wdCollapseEnd
.Text = TxtAlt1Addr3.Value & Chr(13)
.Style = ("BaseAddress Back")
.Collapse wdCollapseEnd
.Text = "Telephone: +" & TxtAlt1Phone & Chr(13)
.Style = ("DirectLine Back")
.Collapse wdCollapseEnd
.Text = "Facsimile: +" & TxtAlt1Fax.Value & Chr(13) & Chr(13)
.Style = ("BaseAddress Back")
.Collapse wdCollapseEnd

.Text = txtAlt2Title1.Value & Chr(13)
.Style = ("TitleAddressWhite")
.Collapse wdCollapseEnd
.Text = TxtAlt2Addr1 & Chr(13)
.Style = ("BaseAddress Back")
.Collapse wdCollapseEnd
.Text = TxtAlt2Addr2.Value & Chr(13)
.Style = ("BaseAddress Back")
.Collapse wdCollapseEnd
.Text = TxtAlt2Addr3.Value & Chr(13)
.Style = ("BaseAddress Back")
.Collapse wdCollapseEnd
.Text = "Telephone: +" & TxtAlt2Phone & Chr(13)
.Style = ("DirectLine Back")
.Collapse wdCollapseEnd
.Text = "Facsimile: +" & TxtAlt2Fax.Value & Chr(13) & Chr(13)
.Style = ("BaseAddress Back")
.Collapse wdCollapseEnd

.Text = TxtAlt3Title1.Value & Chr(13)
.Style = ("TitleAddressWhite")
.Collapse wdCollapseEnd
.Text = TxtAlt3Addr1 & Chr(13)
.Style = ("BaseAddress Back")
.Collapse wdCollapseEnd
.Text = TxtAlt3Addr2.Value & Chr(13)
.Style = ("BaseAddress Back")
.Collapse wdCollapseEnd
.Text = TxtAlt3Addr3.Value & Chr(13)
.Style = ("BaseAddress Back")
.Collapse wdCollapseEnd
.Text = "Telephone: +" & TxtAlt3Phone & Chr(13)
.Style = ("DirectLine Back")
.Collapse wdCollapseEnd
.Text = "Facsimile: +" & TxtAlt3Fax.Value & Chr(13)
.Style = ("BaseAddress Back")
.Collapse wdCollapseEnd
End With

I see.

You could reset your range to that cell after you are done inserting the
text:

Then use that range to "copy" the content to the other cell:

Dim myRg As Range

Set myRg = _
ActiveDocument.Tables(1).Cell(Row:=4, Column:=2).Range.FormattedText
'To remove the end of cell marker
myRg.MoveEnd wdCharacter, -1

ActiveDocument.Tables(1).Cell(Row:=4, Column:=3).Range.FormattedText
= myRg



--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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