+ Reply to Thread
Results 1 to 5 of 5

VBA to kick off audio or jpeg

  1. #1
    Registered User
    Join Date
    08-06-2013
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2003
    Posts
    72

    VBA to kick off audio or jpeg

    Hello,

    I've built a few macros for some tools we run....but I'd like to have some fun with them. Is it possible to have a jpeg appear on the screen at the end or for a macro to kick off an audio file? The file could be kept on another drive etc. I know it's an odd question. I appreciate your help.

    J

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: VBA to kick off audio or jpeg

    Hi JonathanB2,

    The following code will play a .wav file. I have never attempted using jpegs in that way. The 64 bit conditional compilation has never been tested, since I only have 32 bit Excel. You have to supply your own .wav file in the same folder as the file running the code.

    Lewis

    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: VBA to kick off audio or jpeg

    Hi Jonathan82,

    I've coded the following to open an Access database called Test in a directory called C:\Access - it can changed to open any file type (though I've not tried to open a *.wav with it I must say):

    Please Login or Register  to view this content.
    HTH

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: VBA to kick off audio or jpeg

    Robert,

    Your ShellExcecute command string works as follows when run with Windows Vista and Excel 2003:
    a. It runs the default program associated with the .wav file (in my case Windows Media Player) which is visible when played. I tried to make it hidden with a ShellExecute option, but was not successful.
    b. Windows Media Player has to be manually closed.

    Lewis

  5. #5
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: VBA to kick off audio or jpeg

    J,

    After some research I was able to come up with 6 ways to display an image. I imagine there are a lot more, and most are probably more efficient than the ones I came up with:
    a. Embed image on a Sheet using 'Pictures.Insert'.
    b. Embed image on a Sheet using 'Shapes.AddPicture'.
    c. Embed image in a UserForm at design time.
    d. Embed image in a Chart (called 'myChart').
    e. Embed image in a UserForm at run time.
    f. Embed a jpg file in a UserForm at run time.

    Complete code follows along with a sample working file and also a sample .jpg file:
    Please Login or Register  to view this content.
    Lewis
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Use of 'on time' to kick inactive users
    By TKCZBW in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-16-2014, 03:40 AM
  2. Kick out Inactive users except in read only
    By StephanieLilly in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-17-2013, 02:16 PM
  3. if function for free kick times
    By molemeister in forum Excel General
    Replies: 4
    Last Post: 04-21-2010, 09:10 PM
  4. if function for free kick times -
    By molemeister in forum Excel General
    Replies: 1
    Last Post: 04-21-2010, 08:58 PM
  5. Kick Users Out of Sheet
    By Macdave_19 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-17-2007, 05:34 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1