Results 1 to 4 of 4
  1. #1
    Lawman
    Guest

    copy content in table cell

    I am using Word 2000.

    I need to automatically copy an address entered in a cell in table in one part of a document to cells in several other tables in other parts of the same document. VBA coding is fine.

    In the same vein, I'd like to check or uncheck a box (using the characters found in the wingdings font, for example), depending on whether cell in a table contains any text.

  2. #2
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: copy content in table cell

    Maybe something like this:

    <pre>Dim strTemp As String
    strTemp = Tables(1).Cell(1, 1).Range.Text
    ' Trim off the end of cell character
    strTemp = Left(strTemp, Len(strTemp) - 2)
    Tables(2).Cell(2, 2).Range.Text = strTemp
    ' Insert an unchecked box symbol at
    ' bookmark "CheckBox" in the document
    ActiveDocument.Bookmarks("CheckBox").Range.InsertS ymbol _
    CharacterNumber:=9633, Unicode:=True
    </pre>

    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  3. #3
    lawman
    Guest

    Re: copy content in table cell

    Thanks, Geoff. My name is Patrick.

    I am probably somewhere in the "advanced novice" stage of coding VBA macros. Does this code check for the contents of Cell 1 in Table 1, then place a checkmark in cell 2 if it finds text in Cell 1?

    Is there any way to accomplish the same thing with an embedded "If" function. I've done this by testing cells with numeric expressions, but there is no "content" function like in Excel to test for pure text.

  4. #4
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: copy content in table cell

    Patrick,

    This code:

    strTemp = Tables(1).Cell(1, 1).Range.Text
    puts the value of table 1, cell (1,1) into variable strTemp

    strTemp = Left(strTemp, Len(strTemp) - 2)
    Trims the end of cell characters from the string

    Tables(2).Cell(2, 2).Range.Text = strTemp
    Puts the value of that string into the second table in the document, cell(2,2)

    ActiveDocument.Bookmarks("CheckBox").Range.InsertS ymbol _ CharacterNumber:=9633, Unicode:=True
    Puts the special symbol which looks like an unchecked box into the document, at a bookmark (called "CheckBox") which I had previously defined in the document.

    Does that help?
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •