Generating Random Letters [closed]

120

Question: Generating Random Letters [closed]

I am very new in VBA and honestly no idea of the codes/functions needed to use and what their purpose are but I need to make a PowerPoint that includes a Command Button to create a random letter during the presentation. Can vba error you give me the codes and if possible, explain why use those codes? Thank you very much!

Total Answers: 1

34

Answers 1: of Generating Random Letters [closed]

A few Notes

  • This is set up such that it will occur on slide 1.

  • The text box which will contain the letter is named: "Random_Letters"

  • The active x command button which triggers the macro is named "Generate_Random_Letter"

     Sub Generate_Random_Letter_Click()       ' Read this stuff (or dont lol)      ' vba number to letter (chr) https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/character-set-0127      ' vba random  https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/rnd-function       Randomize      Dim upperBound As Integer: upperBound = 90      Dim lowerBound As Integer: lowerBound = 65      Dim randomIndex As Integer: randomIndex = Int((upperBound - lowerBound + 1) * Rnd + lowerBound)        Dim p As Presentation: Set p = ActivePresentation      Dim s As Slide: Set s = p.Slides.Item(1)      Dim t As Shape: Set t = s.Shapes.Item("Random_Letters")      t.TextFrame.TextRange.Text = Chr(randomIndex)   End Sub 

Good Luck, and remember to actually learn the content.