Thread: On Error
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ryan H Ryan H is offline
external usenet poster
 
Posts: 489
Default On Error

Is this what you are wanting?

Sub FindFile()

Dim QuoteNumber As String
Dim Quote1 As String
Dim Quote2 As String

QuoteNumber = InputBox("Please enter QUOTE file name to recall", "X
Technologies LLC")

Quote1 = "C:\Quotes\" & QuoteNumber & ".XLS"

On Error GoTo TryServer
Workbooks.Open filename:=Quote1
On Error GoTo 0

Exit Sub

TryServer:

Quote2 = "\\SERVER3\Jobs\Estimate1\NEW_QUOT1\" & QuoteNumber & ".XLS"
On Error GoTo CantFindQuotes
Workbooks.Open filename:=Quote2
On Error GoTo 0
Exit Sub

CantFindQuotes:

MsgBox "Can't find " & Quote1 & vbNewLine & vbNewLine & "or" & vbNewLine
& vbNewLine & Quote2, vbCritical

End Sub
--
Cheers,
Ryan


"oldjay" wrote:

I want to recall a file that if not on the C drive looks on the server

quotenumber = InputBox("Please enter QUOTE file name to recall", "X
Technologies LLC")

Quote = "C:\Quotes\" & quotenumber & ".XLS"

Quote = "\\SERVER3\Jobs\Estimate1\NEW_QUOT1\" & quotenumber & ".XLS"

Workbooks.Open Filename:=Quote