Results 1 to 6 of 6

Thread: [RESOLVED] Want to delete a full stop in MS Word Table

  1. #1

    Thread Starter
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Resolved [RESOLVED] Want to delete a full stop in MS Word Table

    Hi all,

    I am working on MS Word 2002 and I need you guys help to sort out my problem. I have a table with 3 columns and 25 rows. In each row column 2 ends with a period (.) I want to delete that particular period (full stop) not a period that comes in middle of the paragraph in that cell. How can I do that?

    Any coding help pls.

    Thanks!

    CS.
    Last edited by cssriraman; Jun 25th, 2005 at 06:15 AM.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Want to delete a full stop in MS Word Table

    here is some code to remove periods from the end of each word in the second column of each table in document

    Issue it doesn't work if it is a single character followed by a period, when i try, it adds a paragraph mark instead, don't know if it will matter to you

    VB Code:
    1. Dim t As Table
    2. For Each t In ActiveDocument.tables
    3.        For i = 1 To t.Rows.Count
    4.        t.Cell(i, 2).Select
    5.        
    6.             pos = InStrRev(Selection.Text, ".")
    7.             If Len(Selection.Text) > 5 Then
    8.                 If pos = Len(Selection.Text) - 2 Then
    9.                     mytext = Left(Selection.Text, Len(Selection.Text) - pos + 1)
    10.                     Selection.Text = mytext
    11.                 End If
    12.             End If
    13.     Next
    14. Next

    pete

  3. #3

    Thread Starter
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Want to delete a full stop in MS Word Table

    Hi, I don't want to remove periods from the end of each word. I want to delete the period if it is the last character on the column 2 in Word Table. Thanks! CS.

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Want to delete a full stop in MS Word Table

    here is some code to remove periods from the end of each word in the second column of each table in document
    true it will do that, i just phrased it wrong as i only had one word in each row of column 2

    try it and see

    pete

  5. #5

    Thread Starter
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Want to delete a full stop in MS Word Table

    I just tried your coding. It deleted the entire line except first three characters. For example, I inserted about 20 rows and 3 column table and inserted the text "The." first column of all rows and "The quick. brown .fox j.umps.. over the lazy dog." in all second column and third column is blank. I run your code. It changed the text in all second column as "The".

    I just want to delete the period in "dog." in above example. If I run a macro it should return as "The quick. brown .fox j.umps.. over the lazy dog"

    Thanks! CS.

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Want to delete a full stop in MS Word Table

    i only had a few letters in each cell, but it seemed to be working right

    anyway try again, think it is fixed, works with single letters as well now

    VB Code:
    1. Dim t As Table
    2. For Each t In ActiveDocument.tables
    3.        For i = 1 To t.Rows.Count
    4.        t.Cell(i, 2).Select
    5.                     pos = InStrRev(Selection.Text, ".")
    6.             If Len(Selection.Text) > 2 Then
    7.                 If pos = Len(Selection.Text) - 2 Then
    8.                     mytext = Left(Selection.Text, pos - 1)
    9.                     Selection.Text = mytext
    10.                 End If
    11.             End If
    12.     Next
    13. Next

    pete

Posting Permissions

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



Click Here to Expand Forum to Full Width