I am trying to move the contents of a table in one document into the
cells of a larger table in a second document. The line
doc2.Range(Start:=tbl3.Cell(13, 1), End:=tbl3.Cell(18, 4)) =
tbl2.Range
gives me a "Type Mismatch" error.

How can I make this happen?

Ed

Re: Need help, please, moving text from one table range to another by fumei

fumei
Wed Jan 23 03:49:35 PST 2008

First off, declaring a Range does indeed use a Start, and and End. However,
Start:=tbl3.Cell(13, 1) is NOT a valid value for a Range value. Thus: Type
Mis-match

Start:= needs to be a NUMBER

tbl3.Cell(13, 1) is NOT a number, it is a cell.

Second, I do not know what your other code is like, but I would guess that it
could probably run better using objects. This is a simple example. An
active document, and an already open (but NOT active) document named "Yadda".
The code makes a table object of the third table in the active document, and
a table object in the target document ("Yadda").

Dim ThisDoc As Document
Dim ThatDoc As Document
Dim SourceTable As Table
Dim TargetTable As Table

Set ThisDoc = ActiveDocument
Set ThatDoc = Documents("Yadda")
Set SourceTable = ThisDoc.Tables(3)
Set TargetTable = ThatDoc.Tables(2)

Now you can just transfer contents from one table to the other. You do not
have to make "Yadda" active; you do not have to copy and paste.

TargetTable.Cell(2, 2).Range.Text =
SourceTable.Cell(5,2).Range.Text

This makes Tables(2).Cell(2,2) in "Yadda" the contents of Tables(3).Cell(5,2)
in the active document.

This is a very simple example. You can also use cell objects and dump stuff
even mor eefficiently.

NOTE: you will need to strip off end-of-cell markers using the Range of the
cells, if you want a perfect copy.
Ed from AZ wrote:
>I am trying to move the contents of a table in one document into the
>cells of a larger table in a second document. The line
> doc2.Range(Start:=tbl3.Cell(13, 1), End:=tbl3.Cell(18, 4)) =
>tbl2.Range
>gives me a "Type Mismatch" error.
>
>How can I make this happen?
>
>Ed

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200801/1


Re: Need help, please, moving text from one table range to another by Ed

Ed
Wed Jan 23 05:44:19 PST 2008

Thanks for the reply. Thinking about it afterwards, I realized this
is probably the Excel VBA dialect, not Word! Oops!!

With your reply and a bit more thinking, it's working now.

Thanks again!

Ed

On Jan 23, 4:49=A0am, "fumei via OfficeKB.com" <u37563@uwe> wrote:
> First off, declaring a Range does indeed use a Start, and and End. =A0Howe=
ver,
> Start:=3Dtbl3.Cell(13, 1) is NOT a valid value for a Range value. =A0Thus:=
=A0Type
> Mis-match
>
> Start:=3D =A0 =A0needs to be a NUMBER
>
> tbl3.Cell(13, 1) is NOT a number, it is a cell.

> Second, I do not know what your other code is like, but I would guess that=
it
> could probably run better using objects. =A0This is a simple example. =A0A=
n
> active document, and an already open (but NOT active) document named "Yadd=
a".
> The code makes a table object of the third table in the active document, a=
nd
> a table object in the target document ("Yadda").
>
> Dim ThisDoc As Document
> Dim ThatDoc As Document
> Dim SourceTable As Table
> Dim TargetTable As Table
>
> Set ThisDoc =3D ActiveDocument
> Set ThatDoc =3D Documents("Yadda")
> Set SourceTable =3D ThisDoc.Tables(3)
> Set TargetTable =3D ThatDoc.Tables(2)
>
> Now you can just transfer contents from one table to the other. =A0You do =
not
> have to make "Yadda" active; you do not have to copy and paste.
>
> TargetTable.Cell(2, 2).Range.Text =3D
> =A0 =A0 SourceTable.Cell(5,2).Range.Text
>
> This makes Tables(2).Cell(2,2) in "Yadda" the contents of Tables(3).Cell(5=
,2)
> in the active document.
>
> This is a very simple example. =A0You can also use cell objects and dump s=
tuff
> even mor eefficiently.
>
> NOTE: =A0you will need to strip off end-of-cell markers using the Range of=
the
> cells, if you want a perfect copy.
>
> Ed from AZ wrote:
> >I am trying to move the contents of a table in one document into the
> >cells of a larger table in a second document. =A0The line
> > =A0 =A0doc2.Range(Start:=3Dtbl3.Cell(13, 1), End:=3Dtbl3.Cell(18, 4)) =
=3D
> >tbl2.Range
> >gives me a "Type Mismatch" error.
>
> >How can I make this happen?
>
> >Ed
>
> --
> Message posted via OfficeKB.comhttp://www.officekb.com/Uwe/Forums.aspx/wor=
d-programming/200801/1