Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Why does Excel think it's "Picture 7" instead of "Picture 1?"

Here's a small portion of my macro:

Sheets("Result").Select
Rows("1:4").Select
Selection.Insert Shift:=xlDown
Range("E4").Select
ActiveSheet.Pictures.Insert("C:\v1logo.gif").Selec t
Selection.ShapeRange.IncrementLeft -12#
Selection.ShapeRange.IncrementTop -19.5
ActiveSheet.Shapes("Picture 1").Select
Selection.ShapeRange.IncrementLeft -20.25
Selection.ShapeRange.IncrementTop -0.75
Range("A1").Select

After years of using this, all of the sudden, I'm getting an error at the
8th line, above:
ActiveSheet.Shapes("Picture 1").Select

Excel can't find Picture 1 because, for some reason, the v1logo.gif file is
called Picture 7. Yesterday, Excel thought it was Picture 4. But for years
and years, it's been inserted as Picture 1 so there was never any problem.

I closed Excel and reopened it, thinking that it would think that it would
"reset" to Picture 1, but it didn't.

Any idea how to overcome this error? In the macro, can I call Picture "X"
instead of a specific Picture number? Or, can I say "whatever picture was
just inserted?"

Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Why does Excel think it's "Picture 7" instead of "Picture 1?"

Maybe you can just use a variable to represent the picture when you insert it.
Then you don't have to worry about its name:

Dim myPict As Picture
Set myPict = ActiveSheet.Pictures.Insert("C:\my pictures\hunter.jpg")

'delete any existing picture with that name????
On Error Resume Next
ActiveSheet.Pictures("Picture 1").Delete
On Error Resume Next

With myPict
'rename it???
.Name = "Picture 1"
With .ShapeRange
.IncrementLeft -12#
.IncrementTop -19.5
.IncrementLeft -20.25
.IncrementTop -0.75
End With
End With



crimsonkng wrote:

Here's a small portion of my macro:

Sheets("Result").Select
Rows("1:4").Select
Selection.Insert Shift:=xlDown
Range("E4").Select
ActiveSheet.Pictures.Insert("C:\v1logo.gif").Selec t
Selection.ShapeRange.IncrementLeft -12#
Selection.ShapeRange.IncrementTop -19.5
ActiveSheet.Shapes("Picture 1").Select
Selection.ShapeRange.IncrementLeft -20.25
Selection.ShapeRange.IncrementTop -0.75
Range("A1").Select

After years of using this, all of the sudden, I'm getting an error at the
8th line, above:
ActiveSheet.Shapes("Picture 1").Select

Excel can't find Picture 1 because, for some reason, the v1logo.gif file is
called Picture 7. Yesterday, Excel thought it was Picture 4. But for years
and years, it's been inserted as Picture 1 so there was never any problem.

I closed Excel and reopened it, thinking that it would think that it would
"reset" to Picture 1, but it didn't.

Any idea how to overcome this error? In the macro, can I call Picture "X"
instead of a specific Picture number? Or, can I say "whatever picture was
just inserted?"

Thanks.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Why does Excel think it's "Picture 7" instead of "Picture 1?"

Worked perfectly. Thanks, Dave. Yer a pal.

"Dave Peterson" wrote:

Maybe you can just use a variable to represent the picture when you insert it.
Then you don't have to worry about its name:

Dim myPict As Picture
Set myPict = ActiveSheet.Pictures.Insert("C:\my pictures\hunter.jpg")

'delete any existing picture with that name????
On Error Resume Next
ActiveSheet.Pictures("Picture 1").Delete
On Error Resume Next

With myPict
'rename it???
.Name = "Picture 1"
With .ShapeRange
.IncrementLeft -12#
.IncrementTop -19.5
.IncrementLeft -20.25
.IncrementTop -0.75
End With
End With



crimsonkng wrote:

Here's a small portion of my macro:

Sheets("Result").Select
Rows("1:4").Select
Selection.Insert Shift:=xlDown
Range("E4").Select
ActiveSheet.Pictures.Insert("C:\v1logo.gif").Selec t
Selection.ShapeRange.IncrementLeft -12#
Selection.ShapeRange.IncrementTop -19.5
ActiveSheet.Shapes("Picture 1").Select
Selection.ShapeRange.IncrementLeft -20.25
Selection.ShapeRange.IncrementTop -0.75
Range("A1").Select

After years of using this, all of the sudden, I'm getting an error at the
8th line, above:
ActiveSheet.Shapes("Picture 1").Select

Excel can't find Picture 1 because, for some reason, the v1logo.gif file is
called Picture 7. Yesterday, Excel thought it was Picture 4. But for years
and years, it's been inserted as Picture 1 so there was never any problem.

I closed Excel and reopened it, thinking that it would think that it would
"reset" to Picture 1, but it didn't.

Any idea how to overcome this error? In the macro, can I call Picture "X"
instead of a specific Picture number? Or, can I say "whatever picture was
just inserted?"

Thanks.


--

Dave Peterson

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
paste from excel to works database all it shows is "picture" MLagrone Excel Discussion (Misc queries) 1 October 6th 08 02:58 AM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
To block "to "eliminate" of the picture of form, information Isaac[_2_] Excel Programming 1 June 29th 06 05:49 PM
To block "to "eliminate" of the picture of form, information Isaac[_2_] Excel Programming 0 June 29th 06 04:34 PM
To block "to "eliminate" of the picture of form, information Isaac[_2_] Excel Programming 0 June 29th 06 03:22 PM


All times are GMT +1. The time now is 11:02 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"