Reputation: 2269
I've several hundred Word documents that I need to insert html tags as per below:
a short bold text line
becomes
a short <b>
bold text</b>
line
Does anyone know the easiest and most efficient way of doing this?
Currently looking at doing a macro.
Upvotes: 0
Views: 3805
Reputation: 1
Here is the code, anybody can use it, put the code in VBA module and run it, the macro will automatically add bold in ms Word.
Sub Bo()
'Finding Bold Text
Dim boldWord As String
Dim doc As Document
Set doc = ActiveDocument
With doc.Content.Find
.ClearFormatting
.Font.Bold = True
.Execute
While .Found
boldWord = .Parent.Text
.Parent.Text = "<b>" & boldWord & "</b>"
.Execute
Wend
End With
doc.Content.Find.Execute Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue
End Sub
Upvotes: 0
Reputation: 7625
Here's a solution I found, tested with Word 2010:
In the search and replace dialog,
Leave the Find what: field blank
In the Replace with: put <b>^&</b>
In the Format -> Font section, select Bold
Replace All
This will put the tags around your bold text. Then you can just copy it to put it in the webpage.
Alternatively, you could use Wildcards with search and replace, using the pattern \<b\>(*)\</b\>
.
Upvotes: 2