Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run-Time error '1004' : Select method of Range class failed [email protected] Excel Discussion (Misc queries) 3 March 9th 07 01:36 PM
Select method of Range class failure Stuart[_5_] Excel Programming 3 February 24th 04 06:35 PM
Copy method fails in IIS Domien Excel Programming 0 February 19th 04 02:46 PM
excel97: runtime error 1004 select method of range class failed JMCN Excel Programming 4 December 25th 03 05:32 AM
error 1004 Select method of Range class failed J.E. McGimpsey Excel Programming 1 September 12th 03 07:42 PM


All times are GMT +1. The time now is 03:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"