I need to write a utility (in .net) that will iterate though a word document
and extract words with bold formatting. These will go into a database. No
problem except I'm not sure about writing the VBA to find bold words in a
document.

Has anyone done this before? Could you post some sample code?

Thanks in advance.

Re: Word VBA Help by Dave

Dave
Mon Apr 24 14:47:31 CDT 2006

Hi,

This will get you started:

Dim sBold As String
With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Text = ""
.Font.Bold = True
Do While .Execute
sBold = sBold & Replace(Trim(Selection.Text), Chr(13), "") &
vbCrLf
Loop
End With
End With
Debug.Print sBold

I use the Replace function to remove any boldface hard returns.

HTH,
Dave

"Dana King" <bushido101@hotmail.com> wrote in message
news:eyipqa9ZGHA.4144@TK2MSFTNGP04.phx.gbl...
>I need to write a utility (in .net) that will iterate though a word
>document and extract words with bold formatting. These will go into a
>database. No problem except I'm not sure about writing the VBA to find bold
>words in a document.
>
> Has anyone done this before? Could you post some sample code?
>
> Thanks in advance.
>
>
>



Re: Word VBA Help by Dana

Dana
Mon Apr 24 17:09:42 CDT 2006

Hey Dave, thanks so much, that's just what I needed.

cheers!

"Dave Lett" <davelett@NOaolSPAM.com> wrote in message
news:%23rGVuf9ZGHA.508@TK2MSFTNGP02.phx.gbl...
> Hi,
>
> This will get you started:
>
> Dim sBold As String
> With Selection
> .HomeKey Unit:=wdStory
> With .Find
> .ClearFormatting
> .Text = ""
> .Font.Bold = True
> Do While .Execute
> sBold = sBold & Replace(Trim(Selection.Text), Chr(13), "") &
> vbCrLf
> Loop
> End With
> End With
> Debug.Print sBold
>
> I use the Replace function to remove any boldface hard returns.
>
> HTH,
> Dave
>
> "Dana King" <bushido101@hotmail.com> wrote in message
> news:eyipqa9ZGHA.4144@TK2MSFTNGP04.phx.gbl...
>>I need to write a utility (in .net) that will iterate though a word
>>document and extract words with bold formatting. These will go into a
>>database. No problem except I'm not sure about writing the VBA to find
>>bold words in a document.
>>
>> Has anyone done this before? Could you post some sample code?
>>
>> Thanks in advance.
>>
>>
>>
>
>