By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,498 Members | 1,558 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,498 IT Pros & Developers. It's quick & easy.

Word 2000 Range.Find.Style fails after patch

P: n/a
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.

Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.
Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.