Word 2000 Range.Find.Style fails after patch

  • Thread starter Arjen van der Hulst
  • Start date
A

Arjen van der Hulst

Hi all,

I am trying to implement some Word-automation using the range.find-object
(using VB.net and Word 2000, early binding).

The sample underneath worked well, but after installing an 'after SP3 patch'
for Word ('upgrading' it to build 9.0.8216), it stopped working and now
generates the following error when I try to set the style-part of the
range.find object.

System.NullReferenceException: Object reference not set to an instance of an
object.
at Word.Find.set_Style(Object& prop)

The sample below follows various Microsoft documentation I can find, but
apparently someting has changed, and I can't find out what (though of course
I've already tried various things).

Who can help me?

Thanks in advance,
Arjen van der Hulst


== SAMPLE =================

Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim oRng As Word.Range

Try
oWord = CType(CreateObject("Word.Application"), Word.Application)
oWord.Visible = True
oDoc = oWord.Documents.Add()
oRng = oDoc.Content

With oRng.Find

' Following line gives the error
.Style = Word.WdBuiltinStyle.wdStyleHeading1

.Text = "something"
.Execute()
If .Found Then
MsgBox("Found")
Else
MsgBox("Not Found")
End If
End With

oDoc.Close(False)
oDoc = Nothing
oWord.Quit()
oWord = Nothing

Catch ex As Exception
MsgBox("exception:" & " " & ex.ToString)
Finally
If Not oDoc Is Nothing Then oDoc = Nothing
If Not oWord Is Nothing Then oWord = Nothing
End Try

== END OF SAMPLE ===============

When replying directly to me, please remove "REMOVE_THIS." from my
emailaddress.
 
A

Arjen van der Hulst

Seemed that the fault was caused by an after office 2000 SP3 excel patch.
'Repairing' Word via the help-menu, option 'detect and repair' did the trick
to solve my problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top