[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.
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:
Dim t As Table
For Each t In ActiveDocument.tables
For i = 1 To t.Rows.Count
t.Cell(i, 2).Select
pos = InStrRev(Selection.Text, ".")
If Len(Selection.Text) > 5 Then
If pos = Len(Selection.Text) - 2 Then
mytext = Left(Selection.Text, Len(Selection.Text) - pos + 1)
Selection.Text = mytext
End If
End If
Next
Next
pete
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.
Re: Want to delete a full stop in MS Word Table
Quote:
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
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.
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:
Dim t As Table
For Each t In ActiveDocument.tables
For i = 1 To t.Rows.Count
t.Cell(i, 2).Select
pos = InStrRev(Selection.Text, ".")
If Len(Selection.Text) > 2 Then
If pos = Len(Selection.Text) - 2 Then
mytext = Left(Selection.Text, pos - 1)
Selection.Text = mytext
End If
End If
Next
Next
pete