Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-22-2015, 10:51 PM
anand anand is offline check character is bold or not Windows 7 64bit check character is bold or not Office 2010 32bit
Novice
check character is bold or not
 
Join Date: Jun 2015
Posts: 15
anand is on a distinguished road
Default check character is bold or not

I need a vba code in word to check whether first character of line is bold or not
Reply With Quote
  #2  
Old 06-23-2015, 02:17 AM
Stefan Blom's Avatar
Stefan Blom Stefan Blom is offline check character is bold or not Windows 7 64bit check character is bold or not Office 2013
Moderator
 
Join Date: Aug 2011
Posts: 4,000
Stefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to all
Default

More details are needed, for anyone to provide a really helpful reply. Do you want to check the first character of each word, the first character of each sentence, or what?

Also, it would help if you described which end result you are trying to achieve.
__________________
Stefan Blom
Microsoft Word MVP

Microsoft 365 apps for business
Windows 11 Professional

Last edited by Stefan Blom; 01-05-2022 at 04:26 PM.
Reply With Quote
  #3  
Old 06-23-2015, 02:58 AM
anand anand is offline check character is bold or not Windows 7 64bit check character is bold or not Office 2010 32bit
Novice
check character is bold or not
 
Join Date: Jun 2015
Posts: 15
anand is on a distinguished road
Default

I have to check first character of each sentence whether it is bold or not.
if sentence starts with number then leave that sentence as it is but if sentence starts with alphabet in bold than i have to delete that sentence.
if first character of sentence is not bold than leave that sentence as it is
Reply With Quote
  #4  
Old 06-23-2015, 04:06 AM
gmayor's Avatar
gmayor gmayor is offline check character is bold or not Windows 7 64bit check character is bold or not Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Based on your description, the following macro shoudl do the job. Test it on a copy of the document:
Code:
Option Explicit
Sub DeleteBoldSentences()
Dim oSentence As Range
    For Each oSentence In ActiveDocument.Range.Sentences
        If Not IsInteger(Asc(oSentence.Characters(1))) Then
            Do While oSentence.Characters.Last = Chr(13)
                oSentence.End = oSentence.End - 1
            Loop
            If oSentence.Characters(1).Font.Bold Then oSentence.Delete
        End If
    Next oSentence
lbl_Exit:
    Set oSentence = Nothing
    Exit Sub
End Sub

Private Function IsInteger(ByVal i As String) As Boolean
    Select Case i
        Case 48 To 57
            IsInteger = True
        Case Else
            IsInteger = False
    End Select
lbl_Exit:
    Exit Function
End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
check character is bold or not How can select from a specific character to another character mohsen.amiri Word 2 02-19-2015 11:38 PM
check character is bold or not Not Bold text but it comes up bold Pluviophile Word 7 10-22-2013 10:29 AM
Format Bold in one line makes all lines bold Nitte Word 2 02-07-2013 12:34 AM
check character is bold or not cannot check/uncheck check box but added check box learn2office Word 1 11-27-2012 02:02 AM
check character is bold or not Using replace to make a word bold and its proceeding character. bostonboi Word 1 01-16-2011 01:54 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:33 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft