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

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
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,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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