Power Point VBA code
Results 1 to 3 of 3

Thread: Power Point VBA code
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Oct 2007
    Location
    Kuwait
    Posts
    449
    Post Thanks / Like
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)

    Default Power Point VBA code

    Hi all,

    I am working on a presentation & I want to show a number that decreases (like a counter) & after looking on some YouTube videos I think it could be achieved much easier with the VBA loop. However, I am having an issue with the below code where it will start with 10 (in presentation mode) but will not show the number 9, 8, 7 … etc. but the screen will freezes until the loop ends & shows me 1 at the end. Any idea what am I doing wrong or how to achieve my goal ?


    Code:
    Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    For X = 10 To 1 Step -1
        ActivePresentation.Slides(1).Shapes("Rectangle 3").Fill.ForeColor.RGB = RGB((X * 10), (X * 10), (X * 10))
        ActivePresentation.Slides(1).Shapes("Rectangle 3").TextFrame2.TextRange.Characters.Text = X
        T = Timer
        Do While Timer - T < 0.5
        Loop
    Next
    End Sub

    Check the List of BB codes


  2. #2
    Board Regular jimrward's Avatar
    Join Date
    Feb 2003
    Location
    Kingdom of Fife
    Posts
    1,681
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Power Point VBA code

    I suggest you look at the timer bit
    T=timer then you test timer-to which would have the same values giving an almost zero result so while loop will never execute
    Have you looked at the wait function

  3. #3
    Board Regular
    Join Date
    Oct 2007
    Location
    Kuwait
    Posts
    449
    Post Thanks / Like
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Power Point VBA code

    Thank you jimrward for your reply. I have developed the some code in excel & it is working as intended. The reason I use timer & not wait function is I don't want to wait 1 second for a number in the loop, I want it to be a bit faster

    Code:
    Sub Count_Down()
    For X = 10 To 1 Step -1
        With Cells(1, 1)
            .Font.Color = vbWhite
            .Interior.Color = RGB((X * 10), (X * 10), (X * 10))
            .Value = X
        End With
        T = Timer
        Do While Timer - T < 0.5
        Loop
    Next
    End Sub

    Check the List of BB codes


Some videos you may like

User Tag List

Tags for this Thread

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
  •