Header
PowerPoint tips, hints and tutorials that will change your presentations for ever!

INDEX

 

Jigsaws
Sounds
Video
Custom Shows
vba code
NaviSlides
Games for teachers
Bullets
Triggers
Security
Flash Cards
Multiple Instances
PowerPoint 2007
Mail Merge
Random events
Animation
Hyperlinks
Set spellcheck language


Home buttonTutorial buttonContact buttonProducts button

Choose A Name

A one slide presentation to choose a random name from a list in a textfile is very useful for example in a class situation but has man other uses. Works in most versions of PowerPoint on Windows.

STEP 1

Create a simple textfile in Notebook. Have one name / line and save on the desktop as Data.txt.

STEP 2

Create a one slide presentation . Make sure that tit has a Title layout.
ALT f11 to get to the vba editor and then INSERT > Module. Paste in the code below.

Sub getName()
Dim rayNames() As String
Dim filenum As Integer
Dim strInput As String
Dim filepath As String
Dim L As Long
filepath = Environ("USERPROFILE") & "\Desktop\Data.txt"
filenum = FreeFile
ReDim rayNames(1 To 1)
Open filepath For Input As filenum
While Not EOF(filenum)
Line Input #filenum, strInput
rayNames(UBound(rayNames)) = strInput
ReDim Preserve rayNames(1 To UBound(rayNames) + 1)
Wend
ReDim Preserve rayNames(1 To UBound(rayNames) - 1)
Randomize
L = Int(Rnd * (UBound(rayNames)) + 1)
ActivePresentation.Slides(1).Shapes(1).TextFrame.TextRange = rayNames(L)
End Sub

 

 

STEP 3

Add a shape to the first slide to call the code. Insert ACTION and choose Run Macro >> getName.

Run the show and click on the shape!

 

Back to the Index Page

POWERPOINT BLOG

Articles on your favourite sport

Free Microsoft PowerPoint Advice, help and tutorials, Template Links
This website is sponsored by Technology Trish Ltd
© Technology Trish 2007
Registered in England and Wales No.5780175
PowerPoint® is a registered trademark of the Microsoft Corporation