I am opening a file, and able to count the cells occupied. Upon attempting to copy data from certain cells, I am receiving a Microsoft Excel error: "The file specified cannot be found. Check the spelling and try again." I used MsgBox to locate my area of issue, but I cannot seem to understand what cannot be found..
Code:
Sub Requirements(wsReview As Worksheet, out_title As String, out_dims As String, ODpath As String)
Dim wbOut As Workbook, wsOut As Worksheet
Dim o_id() As Double, o_n() As Double, o_pt() As Double, o_mt() As Double
strfileexists = Dir(ODpath)
If strfileexists = "" Then
Application.WindowState = xlMaximized
MsgBox ("File: " & ODpath & " not found.")
GoTo Leave_sub
End If
Set wsReview = wsReview
Set wbOut = Workbooks.Open(ODpath)
Set wsOut = wbOut.Worksheets(out_title)
outc = 0
wsOut.Activate
wsOut.Range("A1").Activate
While Not ActiveCell = ""
outc = outc + 1
ActiveCell.Offset(0, 1).Activate
Wend
rowc = outc / 4
ReDim o_id(1 To rowc) As Double
ReDim o_n(1 To rowc) As Double
ReDim o_pt(1 To rowc) As Double
ReDim o_mt(1 To rowc) As Double
MsgBox ("Passed Redim") '<This message appears prior to the error
i = 0
x = 0
wsOut.Activate
While x < rowc
x = x + 1
i = x * 4
o_id(x) = wsOut.Range(wsOut.Cells(1, i - 3)).Value
o_n(x) = wsOut.Range(wsOut.Cells(1, i - 2)).Value
o_pt(x) = wsOut.Range(wsOut.Cells(1, i - 1)).Value
o_mt(x) = wsOut.Range(wsOut.Cells(1, i)).Value
Wend
MsgBox ("Collected data") '<This message does not appear prior to error
x = 0
wsReview.Activate
wsReview.Range("F11").Activate
While x < rowc
x = x + 1
wsReview.Range(wsReview.Cells(ir + x, 6)).Value = o_id(x)
wsReview.Range(wsReview.Cells(ir + x, 7)).Value = o_n(x)
wsReview.Range(wsReview.Cells(ir + x, 8)).Value = o_pt(x)
wsReview.Range(wsReview.Cells(ir + x, 9)).Value = o_mt(x)
Wend
wsOut.Activate
ActiveWorkbook.Close
Leave_sub:
End Sub