PC Review


Reply
Thread Tools Rate Thread

Error: The remote server machine does not exist or is unavailable

 
 
Amanda
Guest
Posts: n/a
 
      13th Sep 2009
below is my code.
if i run it once, it works. if i run it twice, it does not. if i run
it the third time, it does.
obviously, something is ticking on and off.
any help would be great
thanks!

With Application.FileSearch
.NewSearch

.LookIn = "C:\Documents and Settings\ga1790-1\Desktop
\Holder"
.Filename = "R2.xls"
If .Execute > 0 Then
For lCount = 1 To .FoundFiles.Count

Set wbresults =
Excel.Application.Workbooks.Open(Filename:=.FoundFiles(lCount),
UpdateLinks:=0)


Killer = .FoundFiles(lCount)
Killer = Split(Killer, "\")
Killer = Killer(UBound(Killer))

Workbooks(Killer).Close False

Kill .FoundFiles(lCount)

Next lCount
End If
End With
 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      14th Sep 2009
"Amanda" <(E-Mail Removed)> wrote in message
news:ec593e5f-ac60-4f40-ab58-(E-Mail Removed)...
> below is my code.
> if i run it once, it works. if i run it twice, it does not. if i run
> it the third time, it does.
> obviously, something is ticking on and off.
> any help would be great
> thanks!
>
> With Application.FileSearch
> .NewSearch
>
> .LookIn = "C:\Documents and Settings\ga1790-1\Desktop
> \Holder"
> .Filename = "R2.xls"
> If .Execute > 0 Then
> For lCount = 1 To .FoundFiles.Count
>
> Set wbresults =
> Excel.Application.Workbooks.Open(Filename:=.FoundFiles(lCount),
> UpdateLinks:=0)
>
>
> Killer = .FoundFiles(lCount)
> Killer = Split(Killer, "\")
> Killer = Killer(UBound(Killer))
>
> Workbooks(Killer).Close False
>
> Kill .FoundFiles(lCount)
>
> Next lCount
> End If
> End With



I don't know for sure, but I think you would be better off explicitly
declaring an Excel Application object variable, setting that variable to a
New Excel.Application, and qualifying all Excel method calls from there.
E.g.,

'------ start of revised code ------
Dim objXL As Excel.Application
Dim wbresults As Excel.Workbook
Dim strFile As String

Set objXL = New Excel.Application

With Application.FileSearch
.NewSearch
.LookIn = "C:\Documents and Settings\ga1790-1\Desktop\Holder"
.Filename = "R2.xls"
If .Execute > 0 Then
For lCount = 1 To .FoundFiles.Count

strFile = :=.FoundFiles(lCount)

Set wbresults =
objXL.Workbooks.Open(Filename:=.strFile, UpdateLinks:=0)

Killer = Mid(strFile, InStrRev(strFile, "\")

set wbresults = Nothing
Workbooks(Killer).Close False

Kill strFile

Next lCount
End If
End With

objXL.Close
'------ end of revised code ------

However, I can't say I understand the point of this code, so I hope you left
a lot out for brevity.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
The remote server machine does not exist or is unavailable (Error 462) Vítor Microsoft Access Form Coding 2 2nd Dec 2010 03:52 AM
Runtime error 462: The remote server machine does not exist or is unavailable Jennifer Robertson Microsoft Access VBA Modules 0 24th May 2009 09:02 PM
Runtime error 462: The remote server machine does not exist or is unavailable Jennifer Robertson Microsoft Access VBA Modules 0 24th May 2009 09:02 PM
The remote server machine does not exist or is unavailable WayneM Microsoft Word New Users 0 21st Mar 2004 08:11 PM
Error 462: The remote server machine does not exist or is unavailable. Amod Microsoft Excel Programming 0 2nd Sep 2003 09:14 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:03 PM.