Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select method of Range fails
Hello,
I got stuck supporting somebody else's macros, and I'm running into an error that only seems to affect Excel 2002 SR-1. The error is a 1004 error: Select method of Range class failed. I've indicated the line on which the error occurs. Here is the code: Dim i As Integer, Item As String, Pic As String, OBJ As Object, Col As Object Dim Count As Integer, Message As String, CalcStat As Integer, ColWid As Double Dim Parray() As String ReDim Parray(100) CalcStat = Application.Calculation If CalcStat < xlManual Then Chg_Calc (xlManual) ********* this Sub just unprotects the sheet Unprotect_Sheet ("CBP(2)") If IsMissing(PName) Then PName = "All" For Each OBJ In ActiveWorkbook.Names If Left$(OBJ.Name, 5) = "rpic_" Then Count = Count + 1 Parray(Count) = OBJ.Name End If Next OBJ Else Count = 1 Parray(1) = PName End If ReDim Preserve Parray(Count) For i = 1 To Count Pic = Parray(i) Item = Mid$(Pic, 6, Len(Pic)) On Error Resume Next On Error GoTo 0 With Worksheets("Graphs").Shapes("Ch_" & Item) .Height = Range("rpic_" & Item).Height .Width = Range("rpic_" & Item).Width .CopyPicture , xlPicture End With ****************** the following line fails Range(Pic).Select Worksheets("CBP(2)").PasteSpecial Format:="Picture", Link:=False, DisplayAsIcon:=False As I mentioned before, this only seems to affect Excel 2002 SR-1. In Excel 2003, Excel 2000, and Excel 97 this code excutes just fine. Any ideas would be appreciated, J |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select method of Range fails
change
Range(Pic).Select to Range(Pic).Parent.Select Range(Pic).Selext -- Regards, Tom Ogilvy "J West" wrote in message ... Hello, I got stuck supporting somebody else's macros, and I'm running into an error that only seems to affect Excel 2002 SR-1. The error is a 1004 error: Select method of Range class failed. I've indicated the line on which the error occurs. Here is the code: Dim i As Integer, Item As String, Pic As String, OBJ As Object, Col As Object Dim Count As Integer, Message As String, CalcStat As Integer, ColWid As Double Dim Parray() As String ReDim Parray(100) CalcStat = Application.Calculation If CalcStat < xlManual Then Chg_Calc (xlManual) ********* this Sub just unprotects the sheet Unprotect_Sheet ("CBP(2)") If IsMissing(PName) Then PName = "All" For Each OBJ In ActiveWorkbook.Names If Left$(OBJ.Name, 5) = "rpic_" Then Count = Count + 1 Parray(Count) = OBJ.Name End If Next OBJ Else Count = 1 Parray(1) = PName End If ReDim Preserve Parray(Count) For i = 1 To Count Pic = Parray(i) Item = Mid$(Pic, 6, Len(Pic)) On Error Resume Next On Error GoTo 0 With Worksheets("Graphs").Shapes("Ch_" & Item) .Height = Range("rpic_" & Item).Height .Width = Range("rpic_" & Item).Width .CopyPicture , xlPicture End With ****************** the following line fails Range(Pic).Select Worksheets("CBP(2)").PasteSpecial Format:="Picture", Link:=False, DisplayAsIcon:=False As I mentioned before, this only seems to affect Excel 2002 SR-1. In Excel 2003, Excel 2000, and Excel 97 this code excutes just fine. Any ideas would be appreciated, J |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Run-Time error '1004' : Select method of Range class failed | Excel Discussion (Misc queries) | |||
Select method of Range class failure | Excel Programming | |||
Copy method fails in IIS | Excel Programming | |||
excel97: runtime error 1004 select method of range class failed | Excel Programming | |||
error 1004 Select method of Range class failed | Excel Programming |