Thread: Finding a file
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Oldjay Oldjay is offline
external usenet poster
 
Posts: 337
Default Finding a file

I didn't tell you everything. After I find and open the workbook I will be
copying information from the found file to the original open file.

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

Application.ScreenUpdating = False
Application.DisplayAlerts = False

If pn = -1 Then
partnumber = InputBox("Please enter PART NUMBER file name to
recall", "Auld Technogologies LLC")
Else
partnumber = pn
End If

Quote = "\\SERVER3\Jobs\Estimate1\TEMPLATE1\PART NUMBER1\" & partnumber
& ".XLS"
On Error GoTo DoesNotExist
Workbooks.Open Quote

DoesNotExist:
Quote = "\\Server3\Database\prodscheduling\approvedpar ts\" & partnumber &
".XLS"
Workbooks.Open Quote

Range("C4:C33").Select
Selection.Copy
Windows(MasterSheet).Activate
Sheets("MAIN").Select
Range("C4").Select
Selection.PasteSpecial Paste:=xlFormulas

"Bernie Deitrick" wrote:

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")

'Use code here to make sure partnumber is valid

Quote = "\\SERVER3\Jobs\Estimate1\TEMPLATE1\PART NUMBER1\" & Partnumber
& ".XLS"
On Error GoTo DoesNotExist
Workbooks.Open Quote
Exit Sub
DoesNotExist:
Quote = "\\Server3\Database\prodscheduling\approvedpar ts\" & Partnumber
& ".XLS"
Workbooks.Open Quote
End Sub

Though you will need more error checking in case the second one doesn't
exist.

HTH,
Bernie
MS Excel MVP

"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