Thread: Finding a file
View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Finding a file

I don't have a way to check this macro here, but I think it should work...

Sub OpenPartNumberWorkbook()
Dim Quote As String
Dim PartNumber As String
Dim Servers As Variant
Servers = Array("\\SERVER3\Jobs\Estimate1\TEMPLATE1\PART NUMBER1\", _
"\\Server3\Database\prodscheduling\approvedparts\" )
PartNumber = InputBox("Please enter PART NUMBER file name to recall" & _
"to recall", "OldTechnogologies LLC")
For X = LBound(Servers) To UBound(Servers)
Quote = Servers(X) & PartNumber & ".xls"
If Len(Quote) Then
Workbooks.Open Filename:=Quote
Exit Sub
End If
Next
MsgBox "File not found!"
End Sub

Note: If this works, then you can add as many server paths to the Array
function call as you want or need to.

--
Rick (MVP - Excel)


"Oldjay" wrote in message
...
I have the follow macro

Sub RecallTemplatePartNumber(Optional pn As Long = -1)
Dim partbook As String
Dim partnumber As String
Dim r As Range


partnumber = InputBox("Please enter PART NUMBER file name to
recall", "OldTechnogologies LLC")

Quote = "\\SERVER3\Jobs\Estimate1\TEMPLATE1\PART NUMBER1\" & partnumber
& ".XLS"

If the file is not found I want to look in

Quote = "\\Server3\Database\prodscheduling\approvedpar ts\" & partnumber
& ".XLS

Workbooks.Open Filename:=Quote