All,
I have a line of code that reads like this....
Private Sub CommandButton2_Click()
Dim str As String
Dim objExcel As Excel.Application
Dim objBook As Excel.Workbook
str = Application.GetOpenFilename("excel files_
(*.xls),*.xls"
Set objExcel = New Excel.Application
Set objBook = objExcel.Workbooks.Open(str)
objBook.Sheets("Sheet1"
.Select
Range("AB2:AB762"
.Select
Selection.Copy
Workbooks("code.xls"
.Activate
Sheets("Sheet2"
.Select
Range("B4"
.Select
ActiveSheet.Paste
ActiveWindow.ActivateNext
Range("AF2:AF762"
.Select
Selection.Copy
ActiveWorkbook.Close
Range("D4"
.Select
ActiveSheet.Paste
Range("B1"
.Select
Sheets("Sheet1"
.Paste
End Sub
The problem is, when the file selection box opens and I find my workbook to open, the macro bugs up and tells me that the document I choose ("86783.xls"
cannot be accessed. What am I missing here? I am trying to get the information from AB1:AB762 into the macro worksheet, etc.
Any help would be great. Thanks in advance.
I have a line of code that reads like this....
Private Sub CommandButton2_Click()
Dim str As String
Dim objExcel As Excel.Application
Dim objBook As Excel.Workbook
str = Application.GetOpenFilename("excel files_
(*.xls),*.xls"
Set objExcel = New Excel.Application
Set objBook = objExcel.Workbooks.Open(str)
objBook.Sheets("Sheet1"
Range("AB2:AB762"
Selection.Copy
Workbooks("code.xls"
Sheets("Sheet2"
Range("B4"
ActiveSheet.Paste
ActiveWindow.ActivateNext
Range("AF2:AF762"
Selection.Copy
ActiveWorkbook.Close
Range("D4"
ActiveSheet.Paste
Range("B1"
Sheets("Sheet1"
End Sub
The problem is, when the file selection box opens and I find my workbook to open, the macro bugs up and tells me that the document I choose ("86783.xls"
Any help would be great. Thanks in advance.