![]() |
|
#1
|
|||
|
|||
|
I need a vba code in word to check whether first character of line is bold or not
|
|
#2
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
||||
|
||||
|
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 |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
How can select from a specific character to another character
|
mohsen.amiri | Word | 2 | 02-19-2015 11:38 PM |
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 |
cannot check/uncheck check box but added check box
|
learn2office | Word | 1 | 11-27-2012 02:02 AM |
Using replace to make a word bold and its proceeding character.
|
bostonboi | Word | 1 | 01-16-2011 01:54 PM |