Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 28th, 2005, 11:47 AM
Authorized User
 
Join Date: Jan 2005
Location: Kuala Lumpur, Fed. Territory, Malaysia.
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Picture iteration

Hi, to everyone!

 I tried to do some animation but could not find out why the following codes cannot iterate through a collection of 3 pics:

  code:
      Sub RunPic()
          Dim i As Long
         Application.ScreenUpdating = False

         Worksheet(4).Shapes("Picture").Activate

      For x = 1 To 3

      ActiveSheet.Shapes("Picture" & i).Visible = False
     Next x

     ActiveSheet.Shapes("Picture" & i).Visible = True
     Application.ScreenUpdating = True

     End Sub

 The runtime error displayed is:" The item with the specified name wasn't found".
 I am using Office 2000 to write those codes.
   The above 3 pics are grouped and named "PICTURE". Is there a better way to iterate pictures, rectangles, ovals and etc., showing each shape one at the time?







      
 
Old September 28th, 2005, 11:59 AM
Friend of Wrox
 
Join Date: Jan 2005
Location: Bournemouth, Dorset, United Kingdom.
Posts: 180
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ungroup your images and have each one called "picture 1", "picture 2", and "picture 3" respectively.


Sub RunPic()
Dim i, PauseTime, Start, Finish, TotalTime
For i = 1 To 3
    PauseTime = 2 ' Set duration of changing sequence.
    Start = Timer
    ActiveSheet.Shapes("Picture " & i).Visible = True
    Do While Timer < Start + PauseTime
        DoEvents
    Loop
    Finish = Timer
    TotalTime = Finish - Start
    ActiveSheet.Shapes("Picture " & i).Visible = False
Next i
End Sub


cheers

Matt

 
Old September 28th, 2005, 12:00 PM
Authorized User
 
Join Date: Feb 2005
Location: , , Netherlands.
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Try this this: replace ActiveSheet.Shapes("Picture" & i).visible = false with
ActiveSheet.OLEObjects("Picture" & i).Visible = True

Hope this helps
-Max

 
Old September 28th, 2005, 12:44 PM
Authorized User
 
Join Date: Jan 2005
Location: Kuala Lumpur, Fed. Territory, Malaysia.
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you to both of you - Matt and Max!!
  Matt's solution is the one I am trying to handle, but somehow the codes that were
a bit familiar in the past had somehow slipped from my memory!
  That was a great help!!!
  Now, I can sleep better tonight!




Similar Threads
Thread Thread Starter Forum Replies Last Post
iteration bostek Excel VBA 5 August 30th, 2006 01:23 AM
iteration movenext weazy Excel VBA 0 June 9th, 2006 05:56 PM
Iteration in struts sridevi Servlets 2 July 1st, 2005 07:01 AM
Iteration through a dropdown. tryxxter PHP How-To 1 February 9th, 2005 11:05 PM
OLE picture - accessing the picture property bdcrisp Excel VBA 0 December 7th, 2003 09:35 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.