anne.gomes
05-22-2014, 03:48 PM
Hi,
For the line : MsgBox "The destination workbook is " & MyWorkbook.Name its saying destination workbook is Book2.xlsm. But when I put it inn, nothing happens and the code doesn't run. No error is thrown but nothing happens either.
Any ideas?
Sub Copy()
Dim MyWorkbook As Workbook
On Error GoTo Errhandler
ChDrive "C:"
ChDir "C:\"
ChDir "C:\test"
On Error GoTo 0
Set MyWorkbook = ActiveWorkbook
MsgBox "The destination workbook is " & MyWorkbook.Name
' Exit the macro so that the error handler is not executed.
Exit Sub
Errhandler:
Select Case Err
Case 68, 75: ' Error 68: "Device not available"
' Error 75: "Path/File Access Error"
MsgBox "There is an error reading drive C."
Case 76: ' Error 76: "Path not found"
MsgBox "The specified path is not found."
Case Else: ' An error other than 68, 75 or 76 has occurred.
MsgBox "Error # " & Err & " : " & Error(Err)
End Select
End Sub
Thanks in advance for your help! :)
For the line : MsgBox "The destination workbook is " & MyWorkbook.Name its saying destination workbook is Book2.xlsm. But when I put it inn, nothing happens and the code doesn't run. No error is thrown but nothing happens either.
Any ideas?
Sub Copy()
Dim MyWorkbook As Workbook
On Error GoTo Errhandler
ChDrive "C:"
ChDir "C:\"
ChDir "C:\test"
On Error GoTo 0
Set MyWorkbook = ActiveWorkbook
MsgBox "The destination workbook is " & MyWorkbook.Name
' Exit the macro so that the error handler is not executed.
Exit Sub
Errhandler:
Select Case Err
Case 68, 75: ' Error 68: "Device not available"
' Error 75: "Path/File Access Error"
MsgBox "There is an error reading drive C."
Case 76: ' Error 76: "Path not found"
MsgBox "The specified path is not found."
Case Else: ' An error other than 68, 75 or 76 has occurred.
MsgBox "Error # " & Err & " : " & Error(Err)
End Select
End Sub
Thanks in advance for your help! :)