vba timeout works in one WB and not the other

andrewb90

Well-known Member
Joined
Dec 16, 2009
Messages
1,075
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?
 

Some videos you may like

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
8,114
Office Version
  1. 2016
Platform
  1. Windows
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.
 

andrewb90

Well-known Member
Joined
Dec 16, 2009
Messages
1,075
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!
 

Watch MrExcel Video

Forum statistics

Threads
1,122,588
Messages
5,597,042
Members
414,116
Latest member
sfullnet

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
Top