Bold formatting for new text in column

C

Compass Rose

I have a table with 3 columns. What code would be used to force any new text
typed into column 2 to be formatted in bold?

TIA
David
 
C

Carim

Hi,

Use conditional formating,
Formula Is
=B1<>""
Format Bold
and apply to the whole column

HTH
Cheers
Carim
 
C

Carim

Sorry Sorry ...

another confusion, I am not attentive enough ...
Could the following be of any help :

Sub Bold2()
Dim oCel As Cell
ActiveDocument.Tables(1).Columns(2).Select
For Each oCel In Selection.Range.Cells
oCel.Range.Font.Bold = True
Next
End Sub

HTH
Cheers
Carim
 
C

Carim

A couple of ideas :

1. At the design stage, if your whole table is still empty, you can set
Column 2 as Bold, and future entries will be automatically bold ... or,

2. More complex, you could write an application event procedure which
would fire on WindowSelectionChange and test the value of
Selection.Cells(1).ColumnIndex ,
if this value is 2 , it will apply Selection.Font.Bold = True

Again all my apologies for the Excel - Word confusion ...

HTH
Cheers
Carim
 
C

Compass Rose

I realize that I wasn't specific enough in my description of what I am trying
to achieve, in an attempt to be brief.

I have an existing table with 3 columns in a document. The entire table is
formatted as regular text. If any new text is added to column 2, I want it to
be formatted BOLD, so that someone reading the table will realize that this
new text has been added. The new text will always appear at the end of the
existing text - never in the middle. I realize that the person can hit Ctrl+B
before typing the new text, but I want to eliminate that requirement, if
possible.
 
C

Compass Rose

Correction:

'If any new text is added to column 2, ....' should read 'If any new text is
added to any of the cells of column 2, ....'
 
C

Compass Rose

Thanks, but I already considered that. It creates too many other problems as
far as typing changes in other locations of the document. Because my macro
does other manipulation of the table, I was hoping to be able to add a few
lines to the macro that would change the formatting of all new text typed in
the cells in column 2 to BOLD but leave all of the exisiing text in the cells
of column 2 as regular formatting.

For example, what would the code be for starting with the first cell of
column 2, going to the end of each cell in column 2, changing the formatting
to BOLD and then inserting a SPACE? Any new text added after the SPACE would
be BOLD. Being new to VBA, I don't know the structure of a 'For Each oCell'
loop or a 'For...Next' loop that would accomplish this.
 
C

Carim

Hi,

Sub Bold3()
Dim oCel As Cell
ActiveDocument.Tables(1).Columns(2).Select
For Each oCel In Selection.Range.Cells
oCel.EndKey Unit:=wdLine ' moves to end
oCel.Font.Bold = wdToggle ' changes to bold
oCel.TypeText Text:=" " ' adds a space
Next
End Sub

Hope this can help ... I am not sure about how you plan to track
repetitive inputs ...
Carim
 
C

Compass Rose

Well, we're making progress, but when I try to run the code, I get a compile
error at the statement 'oCel.EndKey'. The compile error is 'Method or data
error not found'. Any thoughts?
 
C

Carim

Sub Bold4()
Dim Tbl As Table
Dim i As Long
Set Tbl = ActiveDocument.Tables(1)
For i = 1 To Tbl.Rows.Count
Tbl.Cell(i, 2).Select
Selection.EndKey Unit:=wdLine ' moves to end
Selection.Font.Bold = wdToggle ' changes to bold
Selection.TypeText Text:=" " ' adds a space
Next i
End Sub

HTH
Carim
 
C

Compass Rose

That did the trick!! Thanks so much for your help. I learned a lot in the
process.

David
 
C

Carim

Hi,

Glad I could help ... Thanks for the feedback ...
It gave me the opportunity to leave my Excel planet for a short
while...

Cheers
Carim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top