Switching on computer sound using vba (1 Viewer)

LOUISBUHAGIAR54

Registered User.
Local time
Today, 13:18
Joined
Mar 14, 2010
Messages
157
I have compiled an access database for patients, that needs to have the computer sound on as a voice is sounded by one of the modules.

The program will be operated by patients themselves, and it may happen that the computer sound or its volume may be switched off during execution of that particular module.

Does anyone know of any code that I can include in the module so as to switch the computer sound on if this happens to be off ? I have made a thorough search and have not managed to find any.

Many thanks for any help or clues.


Louis Buhagiar
 

Solo712

Registered User.
Local time
Today, 16:18
Joined
Oct 19, 2012
Messages
828
I have compiled an access database for patients, that needs to have the computer sound on as a voice is sounded by one of the modules.

The program will be operated by patients themselves, and it may happen that the computer sound or its volume may be switched off during execution of that particular module.

Does anyone know of any code that I can include in the module so as to switch the computer sound on if this happens to be off ? I have made a thorough search and have not managed to find any.

Many thanks for any help or clues.


Louis Buhagiar

Try this:

http://access.mvps.org/access/api/api0011.htm

Best,
Jiri
 

LOUISBUHAGIAR54

Registered User.
Local time
Today, 13:18
Joined
Mar 14, 2010
Messages
157
Thanks for your reply.

Which part of the code switches on the computer sound if it is switched off ? Thanks.
 

Solo712

Registered User.
Local time
Today, 16:18
Joined
Oct 19, 2012
Messages
828
Thanks for your reply.

Which part of the code switches on the computer sound if it is switched off ? Thanks.

The routines play the sound. If you want to switch off the playback of a sound file you create a switch which will bypass the sound-playing module,

Best,
Jiri
 

LOUISBUHAGIAR54

Registered User.
Local time
Today, 13:18
Joined
Mar 14, 2010
Messages
157
Thanks Jiri for your help.

I always want the sound to be uttered by the computer. My difficulty is that someone might switch the sound off, or reduce the volume of the sound on the computer. In that case I want to code to note this has happened and the switch the computer sound and volume on. Is this possible using access vba ?
 

Solo712

Registered User.
Local time
Today, 16:18
Joined
Oct 19, 2012
Messages
828
Thanks Jiri for your help.

I always want the sound to be uttered by the computer. My difficulty is that someone might switch the sound off, or reduce the volume of the sound on the computer. In that case I want to code to note this has happened and the switch the computer sound and volume on. Is this possible using access vba ?

Oh, I get it now. I misread you thinking you were looking for sound-playing routines. Unfortunately, the sound control after Win XP has become quite complex. See here. I haven't looked into this deep enough to be able to give you an intelligent lead. I wish you good luck.

Best,
Jiri
 

LOUISBUHAGIAR54

Registered User.
Local time
Today, 13:18
Joined
Mar 14, 2010
Messages
157
I have done some more research and found a very practical solution to my own problem.

There is a .exe file called nircmd.exe which one can download from www.nirsoft.net. I downloaded this file, unzipped it and placed it in a folder. Then I used the Shell() command within my access code to call this file.

The code to switch the volume on and to increase the sound is then simple and runs as follows:

Dim works As String
'the following is code to switch on sound if muted.download file nircmd.exe and place it somewhere
works = "C:\Users\Louis\Desktop\nircmd\nircmd.exe mutesysvolume 0"
Shell (works)
'the following increases the sound to maximum
works = "C:\Users\Louis\Desktop\nircmd\nircmd.exe setsysvolume 65535"
Shell (works)

Thanks for your help.
 

vbaInet

AWF VIP
Local time
Today, 21:18
Joined
Jan 22, 2010
Messages
26,374
I think I've come across that nirsoft product before. The problem here, as with all exe, is whether your client is happy to install this software on all machines that run your application?

Have you looked into Winmgt and WScript?
 

LOUISBUHAGIAR54

Registered User.
Local time
Today, 13:18
Joined
Mar 14, 2010
Messages
157
In this case I have no problem as the client is myself and I will be downloading the software on the company's computers.

I will look into your suggestions. Many thanks.


Louis Buhagiar
 

vbaInet

AWF VIP
Local time
Today, 21:18
Joined
Jan 22, 2010
Messages
26,374
Well since you're the client then there's no obstacle there :D

One other thing you could look into, and if this is a recurring problem, is to look into setting up a Windows group policy that denies users the right to control the volume. I believe there's a policy for that.
 

LOUISBUHAGIAR54

Registered User.
Local time
Today, 13:18
Joined
Mar 14, 2010
Messages
157
Yes I will look into that. It may be an alternative. In any case the code I came up with is functioning well and it switches the sound on and increases the volume as expected. Many thanks.
 

Users who are viewing this thread

Top Bottom