BigJimSlade
Registered User.
- Local time
- Today, 14:03
- Joined
- Oct 11, 2000
- Messages
- 173
Hey, Big Jim here:
This one has been bugging me for a while, so here I am turning it over to our lovely forum. Here is the problem:
This code is set to copy and paste from file A to file B....twice! The first time, it works great. The second time, I get an automation error:
2147023174(800706ba)
The RPC server is unavailable
I am using Windows NT and Access 97, Word 97
Here is my code:
Private Sub Form_Load()
Dim i As Variant
Dim WordObj As Word.Application
Dim WordDoc As Word.Document
Dim WordDoc1 As Word.Document
For i = 1 To 2
Set WordObj = New Word.Application
Set WordDoc = .Documents.Open("C:\Test.Doc")
WordDoc.Range.Copy
Set WordDoc1 = .Documents.Open("C:\TestA.doc")
WordDoc1.Activate
Selection.Paste
WordDoc1.Close (wdSaveChanges)
WordDoc.Close (wdSaveChanges)
DoEvents
PauseIta (5) ' This is just a function I use to create a pause
WordObj.Quit
End With
Set WordDoc = Nothing
Set WordDoc1 = Nothing
Set WordObj = Nothing
Next i
End Sub
The error occurs the second time I run the line "Selection.Paste". Thanks everyone for taking a look at it. I always appreciate your time.
Big Jim
This one has been bugging me for a while, so here I am turning it over to our lovely forum. Here is the problem:
This code is set to copy and paste from file A to file B....twice! The first time, it works great. The second time, I get an automation error:
2147023174(800706ba)
The RPC server is unavailable
I am using Windows NT and Access 97, Word 97
Here is my code:
Private Sub Form_Load()
Dim i As Variant
Dim WordObj As Word.Application
Dim WordDoc As Word.Document
Dim WordDoc1 As Word.Document
For i = 1 To 2
Set WordObj = New Word.Application
Set WordDoc = .Documents.Open("C:\Test.Doc")
WordDoc.Range.Copy
Set WordDoc1 = .Documents.Open("C:\TestA.doc")
WordDoc1.Activate
Selection.Paste
WordDoc1.Close (wdSaveChanges)
WordDoc.Close (wdSaveChanges)
DoEvents
PauseIta (5) ' This is just a function I use to create a pause
WordObj.Quit
End With
Set WordDoc = Nothing
Set WordDoc1 = Nothing
Set WordObj = Nothing
Next i
End Sub
The error occurs the second time I run the line "Selection.Paste". Thanks everyone for taking a look at it. I always appreciate your time.
Big Jim