+ Reply to Thread
Results 1 to 10 of 10

On workbook open, displaly Picture while Wav file playing, then hide picture.

  1. #1
    Registered User
    Join Date
    03-16-2013
    Location
    LI, NY
    MS-Off Ver
    Excel 2007
    Posts
    7

    On workbook open, displaly Picture while Wav file playing, then hide picture.

    I've tried to use App.OnTime and App.Wait features and can't seem to get the code to work properly. What I have now is when I open a workbook, I have a WAV file play. What I want is to have a picture displayed while the WAV file is playing. I tried to break to process up into different macro's. I tried the OnTime and Wait features and I have searched many online sites, but still can't get it to work properly. What happens is the picture will only flicker. You know, on and off in a micro-second. I have gotten error messages using OnTime stating that the macro does not exist or macro's are not permitted in this workbook? I must be overlooking something somewhere. A simple example of the proper code that works is all I need. Please help!

  2. #2
    Forum Contributor
    Join Date
    01-25-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    434

    Re: On workbook open, displaly Picture while Wav file playing, then hide picture.

    can we see the file that you're currently working with

  3. #3
    Forum Contributor
    Join Date
    10-30-2013
    Location
    Melbourne
    MS-Off Ver
    Excel 2013
    Posts
    173

    Re: On workbook open, displaly Picture while Wav file playing, then hide picture.

    Hi, based on my understanding if your aim from the thread title, you need to use the Workbook Open event. Try searching that.


    Sent from my iPhone using Tapatalk

  4. #4
    Registered User
    Join Date
    03-16-2013
    Location
    LI, NY
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: On workbook open, displaly Picture while Wav file playing, then hide picture.

    Sorry for the delay. Life is just full of obligations.

    Here is an example of what I've tried. Just trying to get the pic to display for 4 seconds.

    Private Sub Worksheet_Activate()
    Call PicOn
    Call waiton
    Call picoff
    End Sub

    Sub waiton()

    Application.Wait (Now + #12:00:04 AM#)
    End Sub

    Sub PicOn()
    Sheets("Sheet2").Shapes("Picture 1").Visible = True
    End Sub

    Sub picoff()
    Sheets("Sheet2").Shapes("Picture 1").Visible = False
    End Sub

    The pic flickers on and off once after the 4 seconds of wait time. Why doesn't display before the wait?

  5. #5
    Forum Contributor
    Join Date
    10-30-2013
    Location
    Melbourne
    MS-Off Ver
    Excel 2013
    Posts
    173

    Re: On workbook open, displaly Picture while Wav file playing, then hide picture.

    Try adding a call to DoEvents as per below...

    Private Sub Worksheet_Activate()
    Call PicOn
    DoEvents 'Edit
    Call waiton
    Call picoff
    End


    Sent from my iPhone using Tapatalk

  6. #6
    Registered User
    Join Date
    03-16-2013
    Location
    LI, NY
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: On workbook open, displaly Picture while Wav file playing, then hide picture.

    Thanks for the try, but that didn't work either. However I found that if I add a one second wait to PicOn, then it works.

    Sub PicOn()
    Sheets("Sheet2").Shapes("Picture 1").Visible = True
    Application.Wait (Now + #12:00:01 AM#)
    End Sub

    Now I just add my WAV file and it works fine. Again, thanks for the attempt and I'm satisfied with my solution. It may not be the best, but it works. I am still open for any other solutions that might be more proper, for I'm still learning as most of us are.

  7. #7
    Forum Contributor
    Join Date
    10-30-2013
    Location
    Melbourne
    MS-Off Ver
    Excel 2013
    Posts
    173

    Re: On workbook open, displaly Picture while Wav file playing, then hide picture.

    Hmm, interesting... Did you try putting the do events statement directly after setting the pic to visible in the picon sub? Also try it without the call statements. You don't need those anyway so you may as well get rid of them.


    Sent from my iPhone using Tapatalk

  8. #8
    Registered User
    Join Date
    03-16-2013
    Location
    LI, NY
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: On workbook open, displaly Picture while Wav file playing, then hide picture.

    Yes. I put the do events after the picon call statement and I also tried it after the pic true in the picon macro. In both cases the pic would just flicker.

  9. #9
    Forum Contributor
    Join Date
    10-30-2013
    Location
    Melbourne
    MS-Off Ver
    Excel 2013
    Posts
    173

    Re: On workbook open, displaly Picture while Wav file playing, then hide picture.

    Good thinking to move things around... this stuff is quirky in VBA so you are wise to experiment.

    Just for the record, this also works...

    In Sheet2 Module
    Please Login or Register  to view this content.
    (I just put the Worksheet_Deactivate event in there and left out the Call statements because of my religious beliefs...)
    Last edited by coolblue; 06-03-2014 at 11:04 PM.

  10. #10
    Registered User
    Join Date
    03-16-2013
    Location
    LI, NY
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: On workbook open, displaly Picture while Wav file playing, then hide picture.

    Yes, yes, I like that better. It eliminates the extra second of wait time. Thanks again.

+ 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. Click on picture and run macro to replace existing picture with selected picture file
    By houseflipsheet in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-14-2014, 12:02 AM
  2. Replies: 3
    Last Post: 10-24-2012, 08:15 PM
  3. How to open a picture from an other worksheet in the same workbook?
    By Vizipˇk in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 10-01-2012, 11:25 AM
  4. [SOLVED] macro: insert picture based on workbook location, not picture root path.
    By NicksDad in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-03-2012, 07:47 AM
  5. [SOLVED] how do i open a picture file by clicking on a certain cell?
    By amroshious in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-03-2006, 04:25 PM

Tags for this Thread

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