vba timeout works in one WB and not the other

andrewb90

Well-known Member
Joined
Dec 16, 2009
Messages
1,077
hello all:

I have this code:
Code:
Sub grower() 'this centers object and gradually makes bigger    
    Dim myPicture As Shape
     
    Set myPicture = ActiveSheet.Shapes("zax1")
     
    With ActiveWindow.VisibleRange
        myPicture.Top = .Top + .Height / 2 - myPicture.Height / 2
        myPicture.Left = .Left + .Width / 2 - myPicture.Width / 2
    End With
    myPicture.Visible = True
    rep_count = 0
    Do
    DoEvents
    'MsgBox "HI"
        ActiveSheet.Shapes("zax1").Height = ActiveSheet.Shapes("zax1").Height + 20
        ActiveSheet.Shapes("zax1").Width = ActiveSheet.Shapes("zax1").Width + 20
        'Sheet2.Shapes("zax1").Rotation = rep_count * 5
        With ActiveWindow.VisibleRange
            myPicture.Top = .Top + .Height / 2 - myPicture.Height / 2
            myPicture.Left = .Left + .Width / 2 - myPicture.Width / 2
        End With
    myPicture.Visible = True
        rep_count = rep_count + 1
        timeout (0.22)
Loop Until rep_count = 10
End Sub

In my test workbook, this works perfect, but in my actual workbook I want it in
timeout is highlighted and a compile error pops up. anybody have any idea why?
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
hello all:

I have this code:
Code:
Sub grower() 'this centers object and gradually makes bigger    
    Dim myPicture As Shape
     
    Set myPicture = ActiveSheet.Shapes("zax1")
     
    With ActiveWindow.VisibleRange
        myPicture.Top = .Top + .Height / 2 - myPicture.Height / 2
        myPicture.Left = .Left + .Width / 2 - myPicture.Width / 2
    End With
    myPicture.Visible = True
    rep_count = 0
    Do
    DoEvents
    'MsgBox "HI"
        ActiveSheet.Shapes("zax1").Height = ActiveSheet.Shapes("zax1").Height + 20
        ActiveSheet.Shapes("zax1").Width = ActiveSheet.Shapes("zax1").Width + 20
        'Sheet2.Shapes("zax1").Rotation = rep_count * 5
        With ActiveWindow.VisibleRange
            myPicture.Top = .Top + .Height / 2 - myPicture.Height / 2
            myPicture.Left = .Left + .Width / 2 - myPicture.Width / 2
        End With
    myPicture.Visible = True
        rep_count = rep_count + 1
        timeout (0.22)
Loop Until rep_count = 10
End Sub

In my test workbook, this works perfect, but in my actual workbook I want it in
timeout is highlighted and a compile error pops up. anybody have any idea why?

Where is the timeout Macro ? the compile error suggests it is nowhere to be found in your workbook project.
 
Upvote 0
oh. I feel dumb now. didn't copy it into the other book. I guess even Rockstars caffeine looses its effectiveness at 6AM.

Thank you!
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,263
Members
452,627
Latest member
KitkatToby

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top