Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2005

Tip: Looking for answers? Try searching our database.

Find Cell Marker in Table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cathy D. - 09 Mar 2005 17:29 GMT
A lot of the templates I make are tables and after the information is merged
into the tables, I usually create a macro to clean up the information.  The
one thing I can't seem to figure out, or don't know if there is a way to do
it, is to search for a cell marker within a table.  I want to be able to
search for a character and a cell marker (e.g., paragraph mark followed by
cell marker), then be able to delete the paragraph mark and put the cell
marker back.  If I just search for the paragraph marker, it will find all of
them in the file, rather than just the ones that are next to a cell marker.
I've needed to be able to do this so many times in the past, but have never
been able to figure out how.  Any help will be greatly appreciated.

Cathy
Jean-Guy Marcil - 09 Mar 2005 19:17 GMT
Cathy D. was telling us:
Cathy D. nous racontait que :

> A lot of the templates I make are tables and after the information is
> merged into the tables, I usually create a macro to clean up the
[quoted text clipped - 8 lines]
> never been able to figure out how.  Any help will be greatly
> appreciated.

THe cell marker is actually two character: Chr(13) and Chr(7).  YOu can test
this with this little macro:
'_______________________________________
Sub CellContent()

Dim CellText As String
Dim CelLen As Long

CellText = Selection.Range.Text

CelLen = Len(CellText)

For i = 1 To CelLen
   MsgBox "Character # " & i & " is " _
       & "Chr(" & Asc(Mid(CellText, i, 1)) & ")"
Next

End Sub
'_______________________________________

Select a cell and its content and run the macro. Choose one that has only a
few characters and that whose last one is a ?.

You notice that the last three characters are Chr(13) (the ?) and
Chr(13)+Chr(7) (the ?).
So you could write a macro to used VB string manipulation and test each cell
content, if you find Chr(13) Chr(13) Chr(7) , then remove the first Chr(13)
of the two. Or, you could use a little macro such as this one:

'_______________________________________
Sub RemoveLastParMark_in_Cell()

Dim CellRage As Range
Dim MyTable As Table
Dim MyCell As Cell

Application.ScreenUpdating = False

With ActiveDocument
   For Each MyTable In .Tables
       For Each MyCell In MyTable.Range.Cells
           Do While MyCell.Range.Characters.Last.Previous = Chr(13)
               MyCell.Range.Characters.Last.Previous.Delete
           Loop
       Next
   Next
End With

Application.ScreenRefresh
Application.ScreenUpdating = True

End Sub
'_______________________________________

I am sure someone will be along shortly with an even faster way of doing
this, but at the moment this all my little brain can concoct!

Cheers.
Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Cathy D. - 09 Mar 2005 19:51 GMT
Hi Jean-Cuy,

Where can I get a list of what all the character numbers are.  For instance,
you state that the paragraph mark is Chr 13.  I would also like to know what
Chr number the comma is??

By the way, thank you very much for your help.

> Cathy D. was telling us:
> Cathy D. nous racontait que :
[quoted text clipped - 70 lines]
>
> Cheers.
Jean-Guy Marcil - 10 Mar 2005 03:10 GMT
Cathy D. was telling us:
Cathy D. nous racontait que :

> Hi Jean-Cuy,
>
[quoted text clipped - 3 lines]
>
> By the way, thank you very much for your help.

Look up ASCII in the online Help, or

select the character you want and run

Dim CharacterCode as Long
CharacterCode = Asc(Selection.Text)
Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Martin Seelhofer - 10 Mar 2005 08:52 GMT
Hey there

> [...]
> select the character you want and run
>
> Dim CharacterCode as Long
> CharacterCode = Asc(Selection.Text)

Or simply type the following into the immediate window in
the VBA-Editor (if it is not displayed, press CTRL + G when
the VBA-Editor is open):

?Asc(Selection.Text)

Cheers,
Martin (who loves the immediate window!)
Jean-Guy Marcil - 10 Mar 2005 14:40 GMT
Martin Seelhofer was telling us:
Martin Seelhofer nous racontait que :

> Hey there
>
[quoted text clipped - 12 lines]
> Cheers,
> Martin (who loves the immediate window!)

You are so right. I have to start using the Immediate window... Never think
about it. Thanks for the reminder!

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Klaus Linke - 10 Mar 2005 23:01 GMT
Sorry for another reminder: Use AscW instead of Asc... That old function won't work for codes above 255.

:-)  Klaus

> Martin Seelhofer was telling us:
> Martin Seelhofer nous racontait que :
[quoted text clipped - 15 lines]
> > Cheers,
> > Martin (who loves the immediate window!)

> You are so right. I have to start using the Immediate window... Never think
> about it. Thanks for the reminder!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.