Solved

VBA Word: Bold cell's text till break line

Posted on 2011-09-08
2
625 Views
Last Modified: 2013-11-28
I need to go through one column in my word table and change font to bold for all characters from the first one to first breakline so that would be the string im interested in:

                zz = Left(oCell.Range.Text, InStr(oCell.Range.Text, Chr(13)) - 1)

Im having difficulties in highlighting the 'zz' part of every cell


With appWord
            For Each oCell In .Tables(1).Range.Columns(2).Cells
                

                With .Selection
                    .Bold = True
                End With
            Next
        End With

Open in new window

0
Comment
Question by:yahooooo
2 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 36501164
You need to work on a document, not application, so I've renamed the variable to emphasise that
With docWord
        For Each oCell In .Tables(1).Range.Columns(2).Cells
            oCell.Range.Paragraphs.First.Range.Bold = True
        Next
    End With

Open in new window

0
 
LVL 3

Author Comment

by:yahooooo
ID: 36501239
sry for confusion, i should put on top Dim appWord As Object as well

works great :D Didnt think that I can treat cell like a word document ;)
 thanks
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now