Hello,
Using Excel as an automation client, I have the following code that loops through a directory and copies data from a set of workbooks. However, upon trying to reference the newly Set workbook I receive the above referenced error.
Any ideas?
While strFile <> ""
Set wb = xlObj.Workbooks.Open(strPath & strFile)
Set ws = wb.Sheets("Datax")
With wb.ActiveSheet
FinalRow = .Cells(Rows.Count, 1).End(xlUp).Row
FinalCol = .Cells(1, Columns.Count).End(xlToLeft).Column
If FinalCol > 26 Then FinalColLtr = Chr(Int((FinalCol - 1) / 26) + 64) & Chr(((FinalCol - 1) Mod 26) + 65)
If FinalCol < 27 Then FinalColLtr = Chr(FinalCol + 64)
Range("A1", FinalColLtr & FinalRow).Copy
End With
Using Excel as an automation client, I have the following code that loops through a directory and copies data from a set of workbooks. However, upon trying to reference the newly Set workbook I receive the above referenced error.
Any ideas?
While strFile <> ""
Set wb = xlObj.Workbooks.Open(strPath & strFile)
Set ws = wb.Sheets("Datax")
With wb.ActiveSheet
FinalRow = .Cells(Rows.Count, 1).End(xlUp).Row
FinalCol = .Cells(1, Columns.Count).End(xlToLeft).Column
If FinalCol > 26 Then FinalColLtr = Chr(Int((FinalCol - 1) / 26) + 64) & Chr(((FinalCol - 1) Mod 26) + 65)
If FinalCol < 27 Then FinalColLtr = Chr(FinalCol + 64)
Range("A1", FinalColLtr & FinalRow).Copy
End With