Image & Sound in Cell

Bob Morrison

New Member
Joined
Dec 11, 2009
Messages
31
In XL 2010 is it possible to have a picture in a Cell and it plays an Audio file if you click on it?
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi Bob
- Paste the code below at the module corresponding to the sheet that contains the picture
- Right click the picture, choose “assign macro” and pick PlayWAV from the list
- When you left click the picture, the sound file will play.

Code:
' sheet module


Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long


Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
    
Sub PlayWAV()
Dim wf$
wf = ThisWorkbook.Path & "\beaming.wav"     ' same path as workbook
PlaySound wf, 0&, SND_ASYNC Or SND_FILENAME
End Sub
 
Upvote 0
Thanks Worf,

I’ll see if I can get it to work but I know little or nothing about VB or Macro’s.

However, I’m here to learn.

Cheers

Bob
 
Upvote 0
No luck so far Worf but I'm still working on it.

I think I may have to replace part of your code with my sound file and location?

Bob
 
Upvote 0
Yes, you will
I think I may have to replace part of your code with my sound file and location?


Also, have you assigned the macro to the picture ?
Did you put the code into the appropriate sheet module?
Right click on picture>>Assign macro>> select macro from list>>OK
 
Upvote 0
OK guys I’m getting something all wrong, so I wonder if you could rewrite the Macro for me given the following information

The sound file path is C:\Users\pc\Desktop\Rex's Stuff\Chair.wma

And the Workbook file path is C:\Users\pc\Desktop\Rex's Stuff\Rex.xlsx


Everything is on sheet 1 of the workbook.

For those wondering what it is I’m trying to achieve the story goes like this.

A friend has had a major Stroke which has left him totally paralysed except for his left arm and non-verbal except for ya and na which is his version of yes and no.

However, his comprehension is fine and he seems to understand everything we say even to laughing at jokes. He can also identify objects by pointing with his left arm, but is unable to read or write even though he was left handed.

So what I am trying to do for a start is make him a six cell spreadsheet with a different picture in each cell that relate to something he would like done. In this case there is a picture of a Chair and if he clicks on it or touches it (touchscreen) a small sound file plays, in this case “Can somebody adjust my chair please”.

This may not work, but it’s worth a try because he can work his TV Remote. (just as well he’s male).:LOL:

I have tried a couple of Augmentative & Alternative Communication programmes but they are not sufficiently editable for my purpose and most are targeting children not stroke victims.

So that’s the background and I’m sure if we can get clicking on the picture of the chair to play the appropriate sound file, the other five cells will follow.

Many Thanks

Bob
 
Upvote 0
Hi Bob

Please test this new version:

Code:
' sheet module


Public Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, _
ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long


Sub OpenPlay()
Dim fp$, lngErr&


fp = "c:\pub\opening.wma"   ' your sound file path here


lngErr = ShellExecute(0, "OPEN", fp, "", "", 0)


End Sub
 
Upvote 0

Forum statistics

Threads
1,217,364
Messages
6,136,118
Members
449,993
Latest member
Sphere2215

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top