Hi,
I've developed an application in Excel 2000 which uses the .Copy method of the Worksheet Object.
In Excel 2000 this works fine, but when run in Excel 97 it throws up a runtime error "Method of worksheet object failed".
The only difference i can see between the two versions is the Object libraries; Excel 8.0 for 97 and Excel 9.0 for 2000, but surely the .Copy method is standard for most of the later versions of Excel.
If anyone has any ideas as to what the problem maybe, please let me know.
My code is as follows:
Dim team As String
Dim value As Double
Dim file As String
team = ActiveSheet.ComboBox1.value
value = Cells(35, 4)
file = "C:\Transfer - Team " & team & ".xls"
If team <> "" Then
If Cells(23, 4).value <> 0 And Cells(33, 4).value <> 0 Then
If value <= 50 Then
Sheets("Transfers"
.Select
Sheets("Transfers"
.Copy 'Code fails here in Excel 97
ChDir "C:\"
ActiveWorkbook.SaveAs Filename:=file, FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveSheet.Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
ActiveWorkbook.Close
MsgBox "Your transfer has been saved as: " & file & _
vbCrLf + "Please email this file to Leigh Moore (leigh.moore@visionexpress.com) for it to be recorded", vbOKOnly + vbInformation, "Transfer Created"
Else
MsgBox "Unable to create transfer, team value exceeds maximum allowed.", vbOKOnly + vbExclamation, "Error"
Exit Sub
End If
Else
GoTo TransError
End If
Else
GoTo TransError
End If
TransError:
MsgBox "Transfer is incomplete, please rectify", vbOKOnly + vbExclamation, "Error"
Exit Sub
Thanks in advance.
Leigh Moore
LJM Analysis Ltd
I've developed an application in Excel 2000 which uses the .Copy method of the Worksheet Object.
In Excel 2000 this works fine, but when run in Excel 97 it throws up a runtime error "Method of worksheet object failed".
The only difference i can see between the two versions is the Object libraries; Excel 8.0 for 97 and Excel 9.0 for 2000, but surely the .Copy method is standard for most of the later versions of Excel.
If anyone has any ideas as to what the problem maybe, please let me know.
My code is as follows:
Dim team As String
Dim value As Double
Dim file As String
team = ActiveSheet.ComboBox1.value
value = Cells(35, 4)
file = "C:\Transfer - Team " & team & ".xls"
If team <> "" Then
If Cells(23, 4).value <> 0 And Cells(33, 4).value <> 0 Then
If value <= 50 Then
Sheets("Transfers"
Sheets("Transfers"
ChDir "C:\"
ActiveWorkbook.SaveAs Filename:=file, FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveSheet.Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
ActiveWorkbook.Close
MsgBox "Your transfer has been saved as: " & file & _
vbCrLf + "Please email this file to Leigh Moore (leigh.moore@visionexpress.com) for it to be recorded", vbOKOnly + vbInformation, "Transfer Created"
Else
MsgBox "Unable to create transfer, team value exceeds maximum allowed.", vbOKOnly + vbExclamation, "Error"
Exit Sub
End If
Else
GoTo TransError
End If
Else
GoTo TransError
End If
TransError:
MsgBox "Transfer is incomplete, please rectify", vbOKOnly + vbExclamation, "Error"
Exit Sub
Thanks in advance.
Leigh Moore
LJM Analysis Ltd