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

Word 2000 / VB.Net Automation Help Required

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

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


P: n/a
Have you solved this problem? If so, I'd be interested in your
solution.

Thanks!

Andrew Cranwell wrote:
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


Nov 21 '05 #2

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

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.