ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Crash on every 2nd run (https://www.excelbanter.com/excel-programming/278226-crash-every-2nd-run.html)

Christof[_4_] September 29th 03 08:04 AM

Crash on every 2nd run
 
The previuous message got fired too quickly. Another try:
Gents,

I get the following behaviour:

In a macro, I open a word doc, and close it again with
the following code:

'open word document
Dim infoDocument As Object
Set infoDocument = CreateObject("Word.Basic")
On Error Resume Next
Set infoDocument = Word.Documents.Open(fileAddress,0,
True, False)

If Err.Number = 0 Then

'do some stuff

end if

'Close the document
infoDocument.Close
If Word.Documents.Count = 0 Then
Word.Application.Quit
End If



The problem is now that the first time after the excel
file is opened, the macro works fine. From the second
time on, it stops working with the following error:
'The remote server machine does not exsist or is
unavailable. From VBAProject'

Can anybody explain/improve my code.

regards,
Christof

Mike Waldron September 29th 03 08:50 PM

Crash on every 2nd run
 
Chritof -
I've had an identical problem with Excel opened from
Outlook. Sue Mosher sent me back the reply below. It
might help.

regards,
Mike

Sue wrote:
Did you also close and set the workbook and worksheet you
were using to Nothing?
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

-----Original Message-----
The previuous message got fired too quickly. Another try:
Gents,

I get the following behaviour:

In a macro, I open a word doc, and close it again with
the following code:

'open word document
Dim infoDocument As Object
Set infoDocument = CreateObject("Word.Basic")
On Error Resume Next
Set infoDocument = Word.Documents.Open(fileAddress,0,
True, False)

If Err.Number = 0 Then

'do some stuff

end if

'Close the document
infoDocument.Close
If Word.Documents.Count = 0 Then
Word.Application.Quit
End If



The problem is now that the first time after the excel
file is opened, the macro works fine. From the second
time on, it stops working with the following error:
'The remote server machine does not exsist or is
unavailable. From VBAProject'

Can anybody explain/improve my code.

regards,
Christof
.



All times are GMT +1. The time now is 11:07 PM.

Powered by vBulletin® Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
ExcelBanter.com