how to export cell value outside word

C

cristian.zanchetta

Hi, I have to export the value of a cell outside word (to database)
but I didn't find anything that can help me.
I found a lot of command but none works.
For example:

ActiveDocument.Tables(1).Cell(2, 1).Range.Text

to retrieve the cell content, give me the right result but there is
one or more squares characters (it depends on cell value) added to the
number to export. This couse an incompatibility with the field of
database. Why there is those hidden characters and how can I remove
them? There is a faster way to do this?
Thank you
 
J

Jay Freedman

The two extra characters at the end of the string are the cell marker
(which appears as the single character ¤ when you display nonprinting
characters). Every cell contains at least the cell marker, even when
it appears to be empty.

You can get the string you want with this code:

st = ActiveDocument.Tables(1).Cell(2, 1).Range.Text
st = Left(st, Len(st) - 2)

or with this code:

Dim rg As Range, st As String
Set rg = ActiveDocument.Tables(1).Cell(2, 1).Range
rg.MoveEnd wdCharacter, -1
st = rg.Text

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
Top