Consulting

Results 1 to 10 of 10

Thread: Strange character on table range text

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Strange character on table range text

    Hi all,

    New here - so thanks in advance for your help.

    I have been automating a word document with some semi sophisticated bits of code and have now got stuck on the easiest thing i am trying to do. I am tring to examine the content of a table cell and change the text according to the current value. The rule is as follows: if it says "Low" change it to "Low to Moderate"; says "Low to moderate" change to "Moderate"; etc

    I am using a field which is acting as a macro call on the neighbouring cell - which is working fine.

    Anyway to get ot the point. I am examining the content of the cell by setting a range on that cell and then examining the .text property of the range and comparing it within a case statement to determine the behaviour.

    The coding is fine BUT the .Text property for the range is coming up with a strange dot following the actual text. i.e. if the table cell says "Low", then the .Text property (examined during debug) is showing as "Low-", but with the hyphen i have shown as a bold dot.

    I have tried trimming this text and saving to a string variable, but the dot is still there. I have tried testing for the word "Low" plus a chr(8) in case it is just a space and no luck and the word plus a chr(9) in case a tab and still no luck.

    How can i clean my text from this mysterious wart, or if not possible include it in my condition when looking for a text match.

    Here is the code just for the heck of it:

    Dim OnRg2 As Range
    With ActiveDocument
        Set OnRg2 = .Tables(1).Rows(1).Cells(2).Range
        End With
    Select Case OnRg2.Text
        Case "Low"
            OnRg2.Text = "Low to Moderate"
        Case "Low to Moderate "
            OnRg2.Text = "Moderate"
        Case "Moderate "
            OnRg2.Text = "Moderate to High"
        Case "Moderate to High "
            OnRg2.Text = "High"
        Case "High "
            OnRg2.Text = "Low"
        End Select
    Thanks for any help.
    Last edited by Aussiebear; 12-28-2024 at 07:45 PM.

Posting Permissions

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