Word 2000 from within VB: Windows 2000: error, Windows ME: ok 
Author Message
 Word 2000 from within VB: Windows 2000: error, Windows ME: ok

The following coding runs fine with Windows ME but fails with Windows 2000.

Option Explicit
Public objWord As Word.Application
Public objDoc As Word.Document
.
    Dim strOldString As String, strNewString As String
    strOldString = "something old"
    strNewString = "something new"
    Set objWord = New Word.Application
    objWord.Visible = False
    Set objDoc = objWord.Documents.Open("C:\OldFile.doc")
    ReplText strOldString, strNewString
    objDoc.SaveAs "C:\NewFile.doc"
    objDoc.Close
.
Private Sub ReplText(strStringOld As String, strStringNew As String)
    objDoc.ActiveWindow.Selection.Find.ClearFormatting  <===================
    objDoc.ActiveWindow.Selection.Find.Replacement.ClearFormatting
    With objDoc.ActiveWindow.Selection.Find
        .Text = strStringOld
        .Replacement.Text = strStringNew
    End With
    objDoc.ActiveWindow.Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Execution stops at <======== or at one of the following statemensts if this
one or the next one is commented out. The error message showed is:
Run-time error '5': Invalid procedure call or argument

I am using Windows 2000 SR-3 c.q. Windows ME with Word 2000 SR-1
and Visual Basic 6.0.

Any help or hints, but especially any solution is welcome.

J. Smits



Sat, 02 Apr 2005 16:07:11 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Word 2000 will not run in Windows 2000

2. VB, Access 2000, and Windows 2000

3. installing vb program in Windows NT, Windows 2000

4. Automating email function within Word 2000 using Access 2000

5. outlook 2000 within windows xp

6. DAO problem within Windows 2000

7. Selecting Fonts within Windows 2000/xp Prof.

8. multithread VB client error in Windows 2000

9. Cause of error (error 6 overflow) in Windows 2000

10. I cant believe it is happening - Windows 2000 and Access 2000 crashes

11. ADO Help doesn't appear (Access 2000, Windows 2000)

12. CR8+VB6+SQL Server 2000 and Windows 2000

 

 
Powered by phpBB® Forum Software