Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Differences between MSWORD9.OLB and MSWORD8.OLB

Status
Not open for further replies.

Karibu

Programmer
Joined
Jul 26, 2001
Messages
5
Location
FI
Hello everyone.

I have a problem with Microsoft Word 9.0 Object Library. I have a VB program which opens a word document, finds certain words and replaces them. This program works perfectly in a computer where is Word 97 installed (which uses MSWORD8.OLB), but I have Word 2000 (which uses MSWORD9.OLB) in my computer and the code does not work. I can compile the code without problem.

Following code causes program to crash when running, so I would appreciate any advise what changes I should make or try. Any text or code sample I have found from MSDN or anywhere else does not help :(

In the code, if you have Word 97 or word 2000 code runs to 'Case "97"' branch. If you have Word 95 code runs to 'Case "95"' branch. Branch 'Case "97"' works if you have Word 97 installed, but it does not work if you have Word 2000 installed. What can I do?

Sub Ole_Word_Replace(sTeksti1 As String, sTeksti2 As String)

On Error GoTo Ole_Word_ReplaceVirhe

gWordApp.Visible = True

Select Case user1.Word
Case "95"
gObjWord.MuokkaaKorvaa sTeksti1, sTeksti2, 0, 0, 0, 0, 0, 0, 0, 1
Case "97"
Dim sana As String
gWordApp.ActiveDocument.Select
With gWordApp.Selection.Find
.Text = sTeksti1
.ClearFormatting
.Replacement.Text = sTeksti2
.Replacement.ClearFormatting
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
gWordApp.Selection.Find.Execute Replace:=wdReplaceAll


Case Else
gObjWord.MuokkaaKorvaa sTeksti1, sTeksti2, 0, 0, 0, 0, 0, 0, 0, 1
End Select

Exit Sub

Ole_Word_ReplaceVirhe:

Ole_Word_Error "Ole_Word_Replace"

Exit Sub

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top