Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Page 3 of 3 FirstFirst 123
Results 21 to 28 of 28

Thread: Fun code

  1. #21
    MrExcel MVP Anne Troy's Avatar
    Join Date
    Feb 2002
    Location
    Westwood NJ
    Posts
    2,582
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hmmm...I replied once already but it didn't stick.

    I'll try again.

    Brian: I think you're probably trying to put in *Public Sub ShowStars()* when all you need to put is *ShowStars* and the Public Sub and () will be added automatically when you hit OK. Procedures must have one-word names.
    ~Anne Troy

  2. #22
    Board Regular Brian from Maui's Avatar
    Join Date
    Feb 2002
    Posts
    8,450
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Dreamboat,

    Got it to run.



    Thanks again!

    Brian

    [ This Message was edited by: Brian from Maui on 2002-04-07 00:57 ]

  3. #23
    Board Regular
    Join Date
    Mar 2002
    Posts
    1,451
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-02 21:23, GeorgeB wrote:
    OK here goes
    Open a fresh workbook, right click on the sheet tab, select “View code”
    This will put you into the VBE (Visual Basic Editor) At the top of the
    Screen click on “Insert” select “Procedure” name them the same as my post
    and paste in the code. Do this twice, once for each procedure.
    Good luck

    You write : open a fresh workbook.
    How can I do it with a existant workbook.
    I have a workbook and I want this macro to run automatickly when I open it.
    Can you give me this procedure?
    Many thanks.

  4. #24
    Board Regular
    Join Date
    Feb 2002
    Location
    Georgia USA
    Posts
    569
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Put the ShowStars Marco in a module, then put this in the thisworkbook code

    Private Sub Workbook_Open()
    Call ShowStars
    End Sub

  5. #25
    Board Regular
    Join Date
    Mar 2002
    Posts
    1,451
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-07 14:35, Paul B wrote:
    Put the ShowStars Marco in a module, then put this in the thisworkbook code

    Private Sub Workbook_Open()
    Call ShowStars
    End Sub
    I have done what you wrote.But when I open the workbook,then I receive a message error on the line :Set NewStar = ActiveSheet.Shapes.AddShape _
    (msoShape4pointStar, LeftPos, TopPos, StarWidth, StarHeight)
    I can not see what this can be wrong.
    Can you help me?
    Thanks

  6. #26
    Board Regular
    Join Date
    Mar 2002
    Posts
    1,451
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-07 14:52, verluc wrote:
    On 2002-04-07 14:35, Paul B wrote:
    Put the ShowStars Marco in a module, then put this in the thisworkbook code

    Private Sub Workbook_Open()
    Call ShowStars
    End Sub
    I have done what you wrote.But when I open the workbook,then I receive a message error on the line :Set NewStar = ActiveSheet.Shapes.AddShape _
    (msoShape4pointStar, LeftPos, TopPos, StarWidth, StarHeight)
    I can not see what this can be wrong.
    Can you help me?
    Thanks

  7. #27
    Board Regular
    Join Date
    Mar 2002
    Posts
    1,451
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-07 23:53, verluc wrote:
    On 2002-04-07 14:52, verluc wrote:
    On 2002-04-07 14:35, Paul B wrote:
    Put the ShowStars Marco in a module, then put this in the thisworkbook code

    Private Sub Workbook_Open()
    Call ShowStars
    End Sub
    I have done what you wrote.But when I open the workbook,then I receive a message error on the line :Set NewStar = ActiveSheet.Shapes.AddShape _
    (msoShape4pointStar, LeftPos, TopPos, StarWidth, StarHeight)
    I can not see what this can be wrong.
    Can you help me?
    Thanks
    Who can give me the solution about this error?
    Many thanks.

  8. #28
    MrExcel MVP
    Colo's Avatar
    Join Date
    Mar 2002
    Location
    Kobe, Japan
    Posts
    1,456
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    2 Thread(s)

    Default

    Hi verluc. I only a few tampered with the code. Please try.

    Public Sub ShowStars()
    Dim StarWidth As Integer, StarHeight As Integer, i As Integer
    Dim shp As Shape, TopPos As Double, LeftPos As Double
    Dim NewStar As Shape
    Randomize
    StarWidth = 50: StarHeight = 50
    For i = 1 To 100
    TopPos = Rnd() * (ActiveWindow.UsableHeight - StarHeight)
    LeftPos = Rnd() * (ActiveWindow.UsableWidth - StarWidth)
    Set NewStar = ActiveSheet.Shapes.AddShape _
    (91, LeftPos, TopPos, StarWidth, StarHeight)
    NewStar.Fill.ForeColor.SchemeColor = Int(Rnd() * 56)
    Delay 0.01
    DoEvents
    Next
    Application.Wait Now + TimeValue("00:00:01")
    For Each shp In ActiveSheet.Shapes
    If shp.Type = 1 Then shp.Delete: Delay 0.01
    Next
    End Sub


    [ This Message was edited by: Colo on 2002-04-09 18:30 ]

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •