Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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?







      
Reply With Quote
  #2 (permalink)  
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

Reply With Quote
  #3 (permalink)  
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

Reply With Quote
  #4 (permalink)  
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!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


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



All times are GMT -4. The time now is 04:08 AM.


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