PDA

View Full Version : soundbite toolbar using VBA



bbapties
2004-08-20, 03:58 PM
Finally Friday!!!!

I have a toolbar in mind that I wonder if anyone can hook me up with an example so I can take it from there and run with it?

I want to have a tool bar with about 10 buttons that activate different audio files "sound bites".
For example : If someone comes up behind me and asks me to do something I can click on my "dave chapel, lil john button" and have it say "WHAT!........OK!" :)

That would be sweet...endless possibilities :veryevil:

Ed Jobe
2004-08-20, 04:32 PM
The easiest, non-programming way, is to use the pgp file to create an external command for it.
For example:
DING, START C:\WINDOWS\MEDIA\DING.WAV, 3,,

Then you toolbar button macro could be:
^C^CDing;

bbapties
2004-08-23, 12:38 PM
thanks, this works great!!

The only things is, I have to keep my media player open for it to play quickly. But I think I'd have that problem no matter what.

Thanks again. This is going to be hilarious!

stig.madsen
2004-08-23, 01:42 PM
You could make macros that play your favorite wav's and call them via buttons. For example:


Private Declare Function PlaySound Lib "winmm.dll" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Const SND_ASYNC = &H1 ' play asynchronously
Private Const SND_FILENAME = &H20000 ' file name

Private Function PlayIt(ByVal fname As String)
PlaySound fname, ByVal 0&, SND_FILENAME Or SND_ASYNC
End Function

Sub PlayTada()
PlayIt "C:\WINNT\MEDIA\tada.wav"
End Sub

^C^C^P(progn (vl-vbarun "PlayTada") (princ))

madcadder
2005-08-23, 08:50 PM
You could make macros that play your favorite wav's and call them via buttons. For example:


Private Declare Function PlaySound Lib "winmm.dll" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Const SND_ASYNC = &H1 ' play asynchronously
Private Const SND_FILENAME = &H20000 ' file name

Private Function PlayIt(ByVal fname As String)
PlaySound fname, ByVal 0&, SND_FILENAME Or SND_ASYNC
End Function

Sub PlayTada()
PlayIt "C:\WINNT\MEDIA\tada.wav"
End Sub

^C^C^P(progn (vl-vbarun "PlayTada") (princ))
(What ever happened to Stig? I remember him from the email days.)

What file format does this code get saved in?

RobertB
2005-08-26, 04:07 AM
What file format does this code get saved in?Most of that is VBA code.

SRBalliet
2005-08-26, 11:42 AM
Although I know nothing of VBA, I lurk about on this forum and try to figure things out. This "sounds" like it could be alot of fun and lighten up the office. How do I apply the VBA routine below for use in AutoCAD. Where should the VBA file be stored? Lets say I want a toolbar with 10 buttons with different sounds, would I need 10 different VBA routines? Sorry for being so dim on this topic. I really don't have the time to learn something new right now, but I like this so much I want it right now. Know what I mean?

madcadder
2005-08-26, 05:52 PM
Robert can fill in the blanks, cause what I know about vba...

The file above I have saved as PlayWavs.dvb
It can be (in my personal folder) anywhere in the support path.
To add new sounds, just work with these three lines.


Sub PlayTada()
PlayIt "C:\WINNT\MEDIA\tada.wav"
End Sub

Here's one:


Sub PlayWelcome()
PlayIt "C:\WINNT\MEDIA\welcome.wav"
End Sub

if the "welcome.wav" is in the media folder under WINNT.

RobertB
2005-08-29, 11:21 PM
Robert can fill in the blanks, cause what I know about vba...
I've attached an Acad.dvb (I'm assuming you don't have one yet) with a simplified approach. As long as that Acad.dvb is in one of AutoCAD's search folders (I recommend the user profile's support folder in this case) the support code will load automatically.

The commnad macro (in 2006-speak) can be very simple. There is no need to add multiple VBA macros simply to use different sounds in my version.

^C^C._VBAStmt;ThisDrawing.PlayIt;C:/Windows/Media/Tada.wav;

SRBalliet
2005-08-30, 12:48 PM
Good Morning,

I put the file "acad.dvb" where I was told to. Made a new toolbar button with the associated macro: ^C^C._VBAStmt;ThisDrawing.PlayIt;C:/WinNT/Media/Tada.wav;

I get this error message when attempting to play:

Command: ._VBAStmt
Expression: ThisDrawing.PlayIt
Syntax Error
Command: C:/WinNT/Media/Tada.wav
Unknown command "C:/WINNT/MEDIA/TADA.WAV". Press F1 for help.

What did I do wrong?

SRBalliet
2005-09-01, 04:10 PM
AutoLisp Forum Manager can this be moved to the VBA Forum since it has turned into a VBA question?

RobertB
2005-09-02, 05:22 AM
I put the file "acad.dvb" where I was told to. Made a new toolbar button with the associated macro: ^C^C._VBAStmt;ThisDrawing.PlayIt;C:/WinNT/Media/Tada.wav;

I get this error message when attempting to play:

Command: ._VBAStmt
Expression: ThisDrawing.PlayIt
Syntax Error
Command: C:/WinNT/Media/Tada.wav
Unknown command "C:/WINNT/MEDIA/TADA.WAV". Press F1 for help.

What did I do wrong?It is likely because you don't have the following line in your Acad.rx file:
acvba.arx

Indeed, you might not even have that file in your support folder. I do, and that's why I did not see this issue.

That statement in the Acad.rx file tells AutoCAD to load the VBA environment. VBAStmt doesn't work too well until that happens. :roll:

SRBalliet
2005-09-02, 01:42 PM
The tada.wav is where it should be, it must be the other problem. I guess I will have to learn a new language.

SRBalliet
2005-09-13, 11:17 AM
After trial and error I finally got the following to work as a tool bar button macro.

^C^C -vbarun; playit;C:/winnt/media/My Mind Is Going.wav ;

Its works great it is an almost instantaneous play once you click the button. Any delay is not even noticeable. People wonder how you can access the sound clip you want so fast!

P.S. the sound clip shown above is from the movie 2001 Space Odyssey, with HAL talking.

Thanks for all who helped.