Help Insert VB script

  • Thread starter Thread starter Freebie
  • Start date Start date
F

Freebie

Hi there:
I would like to insert a small VB script into a power point show.

The simplist script I can think of is:
WScript.Echo "Hello World"

Is it possible to insert VBscripts into a Power Point? I can't seem to make
it work.
Thanks,
Scott
 
PPT doesn't support VBScript (though I suppose you could add it to HTML that
you've had PPT generate, if you want to host the script in a browser).

PPT does support VBA, though.

What do you need to accomplish?
 
Thanks for the reply. I'm not sure what VBA is yet, I'll check.
I am giving a presentation on programming to some young learn's. I am going
to use basic and would like to avoid jumping back and forth from my
presentation in PPt to the script run through another program. The
programming intro is not much programming. Just 30 lines that do something
they are familiar with doing by hand.

If I could, I would like a few PPT slides about what I was going to do, put
a code segment on a slide and talk about it, then run the code segment and
let them watch the action.
 
Freebie said:
Thanks for the reply. I'm not sure what VBA is yet, I'll check.
I am giving a presentation on programming to some young learn's. I am going
to use basic and would like to avoid jumping back and forth from my
presentation in PPt to the script run through another program. The
programming intro is not much programming. Just 30 lines that do something
they are familiar with doing by hand.

Gotcha. VBA is essentially VB + stuff that's specific to the application
it's built into.
If you're familiar with VB, start PowerPoint and press ALT+F11 - you'll feel
right at home.
If I could, I would like a few PPT slides about what I was going to do, put
a code segment on a slide and talk about it, then run the code segment and
let them watch the action.

You're covered. Once the VBA editor is open, you can leave it up and switch
between it and your presentation using the task bar.
 
I can't seem to get my code to write out results. It hangs up at Writeline
or WScript.Echo. Any suggestions?
Thanks,

Sub FindValue()
Dim Counter
Dim AnyWord
Dim WordValue
WordValue = 0
AnyWord = "NOVEL"
For Counter = 1 To Len(AnyWord)
WordValue = WordValue + (Asc(Mid(AnyWord, Counter, 1)) - 64)
Next
Writeline AnyWord
WScript.Echo WordValue
End Sub
 
Freebie said:
I can't seem to get my code to write out results. It hangs up at Writeline
or WScript.Echo. Any suggestions?
Thanks,

That's one of the diffs between scripting and VB or VBA ... you don't have a
"console" to write to/read from, so you have to do things differently.

Also, it's good practice to declare your variables explicitly - VBScript is
a bit different.

Sub FindValue()
Dim Counter as Long
Dim AnyWord as String
Dim WordValue as Long

WordValue = 0
AnyWord = "NOVEL"

For Counter = 1 To Len(AnyWord)
WordValue = WordValue + (Asc(Mid(AnyWord, Counter, 1)) - 64)
Next Counter ' "Counter" isn't really required, but it makes the
code easier to follow

Msgbox AnyWord & vbcrlf & "WordValue is: " & cstr(WordValue)

End Sub
 
Thanks! I'll give it a try.

Steve Rindsberg said:
That's one of the diffs between scripting and VB or VBA ... you don't have a
"console" to write to/read from, so you have to do things differently.

Also, it's good practice to declare your variables explicitly - VBScript is
a bit different.

Sub FindValue()
Dim Counter as Long
Dim AnyWord as String
Dim WordValue as Long

WordValue = 0
AnyWord = "NOVEL"

For Counter = 1 To Len(AnyWord)
WordValue = WordValue + (Asc(Mid(AnyWord, Counter, 1)) - 64)
Next Counter ' "Counter" isn't really required, but it makes the
code easier to follow

Msgbox AnyWord & vbcrlf & "WordValue is: " & cstr(WordValue)

End Sub

you'll
 
Back
Top