ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Select method of Range fails (https://www.excelbanter.com/excel-programming/300619-select-method-range-fails.html)

J West

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


Tom Ogilvy

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





All times are GMT +1. The time now is 04:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com