Word 2000 / VB.Net Automation Help Required

A

Andrew Cranwell

Hi,

Please redirect me if I am in the wrong group for this question... this is
my first post to this group, so I hope it is clear!

I am working on an automation project in VB.NET and have to interact with
Word 2000 SP-3 to find and replace text within a word document.
Unfortunately, development (not created by me!) occured with Word 2000 SR-1
and on ugrading the references and version to SP-3, some of the code
inexplicably stopped working, I am hoping somebody might be able to help me
here with suggestions of why the failure is occuring.

Debugging had become difficult too - if I try to debug the application,
Visual Studio debugger quits when executing the call to set my Word.Find
object to the value of WordApplication.Selection.Find - this is very
strange, and again any support to solve this would be really appreciated.

The code - previously this worked with SR-1, but with SP-3 now fails:

Private WordApplication As Word.Application
WordApplication = DirectCase(CreateObject("Word.Application"),
Word.Application)
WordDocument = WordApplication.Documents.Open("MyDocFile.Doc")


Dim Search As Word.Find = WordApplication.Selection.Find

' ** FAILURE occurs here... when ClearFormatting called an ActiveX Object
not found error occurs.
' ** Debugger quits if you try to run next line and breaking on
Search.ClearFormatting and trying to watch
' ** the object also causes Debugger to quit - at this point
Word.Application seems to be null...

Search.ClearFormatting()
Search.Text = SubstanceName & "=" & Substance & ControlChars.Cr &
TreatmentName & "=" & Treatment & ControlChars.Cr & SubjectName & "=" &
Subject
Search.Replacement.Text = ""
Search.Forward = True
Search.Wrap = Word.WdFindWrap.wdFindContinue
Search.Format = False
Search.MatchCase = True
Search.MatchWholeWord = False
Search.MatchWildcards = False
Search.MatchSoundsLike = False
Search.MatchAllWordForms = False
Search.Execute()

Many thanks for your help,

Kind Regards,

Andrew
 
A

Andrew

Molly,

There is a Microsoft solution to this, you have to re-register the word
type library.

Use this batch file.

Echo.Automation Client Fix v1.00
Echo.
Echo.This fix re-registers the Word library files due to corruption from
service pack and other updates.
Echo.This is a known Microsoft bug with Office and occurs due to the
re-use of unique Interface ID's (GUID).
Echo.
Echo.Microsoft Reference: Q292744 -
http://support.microsoft.com/?id=292744
Echo.
"C:\WINNT\SYSTEM32\URTTemp\Regtlib.exe" "C:\Program Files\Microsoft
Office\Office\msword9.olb"
Echo.
Echo.Registration Complete
Echo.
@Pause
 

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