Solved

VBA Word: Bold cell's text till break line

Posted on 2011-09-08
2
622 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

705 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

15 Experts available now in Live!

Get 1:1 Help Now