IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Macros et VBA Excel Discussion :

Macro et Excel ne répond plus [Toutes versions]


Sujet :

Macros et VBA Excel

  1. #1
    Membre du Club
    Homme Profil pro
    Technicien d'usinage
    Inscrit en
    Juillet 2017
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Technicien d'usinage

    Informations forums :
    Inscription : Juillet 2017
    Messages : 132
    Points : 62
    Points
    62
    Par défaut Macro et Excel ne répond plus
    Bonjour à tous,

    Dans mon fichier Excel j'utilise des fichier audio .Wav pour faire une petite présentation d'un fichier compliquer a comprendre.

    Cependant quand je lance cette présentation
    Excel ne répond plus et reste figer. mais pendant cette présentation je montre des cellules d'une couleur etc etc.

    Voici un bout de mon code

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    Declare PtrSafe Function sndPlaySound32 Lib "C:\WINDOWS\SYSTEM32\winmm.dll" _
        Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _
        ByVal uFlags As Long) As Long
     
    Sub Audio ()
    Call sndPlaySound32("C:\Users\sebog\Desktop\Audio Guide\Bienvenue dans le gu.wav ", 0)
    end sub
    Cordialement

  2. #2
    Expert éminent
    Avatar de jurassic pork
    Homme Profil pro
    Bidouilleur
    Inscrit en
    Décembre 2008
    Messages
    3 951
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Bidouilleur
    Secteur : Industrie

    Informations forums :
    Inscription : Décembre 2008
    Messages : 3 951
    Points : 9 280
    Points
    9 280
    Par défaut
    hello,
    c'est normal que ça bloque car tu effectues ta lecture de son en mode synchrone. Il faut effectuer cette lecture en mode asynchrone comme ceci par exemple :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Call sndPlaySound32("C:\Users\sebog\Desktop\Audio Guide\Bienvenue dans le gu.wav ", 1)
    Flags Table===========
    SND_ALIAS = &H10000: lpszName is a string identifying the name of the system event sound to play.
    SND_ALIAS_ID = &H110000: lpszName is a string identifying the name of the predefined sound identifier to play.
    SND_APPLICATION = &H80: lpszName is a string identifying the application-specific event association sound to play.
    SND_ASYNC = &H1: Play the sound asynchronously -- return immediately after beginning to play the sound and have it play in the background.
    SND_FILENAME = &H20000: lpszName is a string identifying the filename of the .wav file to play.
    SND_LOOP = &H8: Continue looping the sound until this function is called again ordering the looped playback to stop. SND_ASYNC must also be specified.
    SND_MEMORY = &H4: lpszName is a numeric pointer refering to the memory address of the image of the waveform sound loaded into RAM.
    SND_NODEFAULT = &H2: If the specified sound cannot be found, terminate the function with failure instead of playing the SystemDefault sound. If this flag is not specified, the SystemDefault sound will play if the specified sound cannot be located and the function will return with success.
    SND_NOSTOP = &H10: If a sound is already playing, do not prematurely stop that sound from playing and instead return with failure. If this flag is not specified, the playing sound will be terminated and the sound specified by the function will play instead.
    SND_NOWAIT = &H2000: If a sound is already playing, do not wait for the currently playing sound to stop and instead return with failure.
    SND_PURGE = &H40: Stop playback of any waveform sound. lpszName must be an empty string.
    SND_RESOURCE = &H4004: lpszName is the numeric resource identifier of the sound stored in an application. hModule must be specified as that application's module handle.
    SND_SYNC = &H0: Play the sound synchronously -- do not return until the sound has finished playing.
    Ami calmant, J.P
    Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

  3. #3
    Membre du Club
    Homme Profil pro
    Technicien d'usinage
    Inscrit en
    Juillet 2017
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Technicien d'usinage

    Informations forums :
    Inscription : Juillet 2017
    Messages : 132
    Points : 62
    Points
    62
    Par défaut
    Bonjour

    Merci J.P pour la réponse effectivement ca va beaucoup mieux =)

    cependant j'ai plusieurs bout d'audio et donc il se lance tous d'un coup.. (et sa fait un peu peur )

    Je peux mettre des Tempo mais celle ci vont quand même bloquer le fichier

    Cordialement

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    Call sndPlaySound32("C:\Users\sebastien.sordet\Desktop\Audio Guide\Les étiquettes font .wav ", 1)
     
    Call sndPlaySound32("C:\Users\sebastien.sordet\Desktop\Audio Guide\Toutes les étiquette.wav ", 1)

  4. #4
    Rédacteur

    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Août 2013
    Messages
    947
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Oise (Picardie)

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : Finance

    Informations forums :
    Inscription : Août 2013
    Messages : 947
    Points : 4 058
    Points
    4 058
    Par défaut
    Bonjour.
    Pour mettre une temporisation sans bloquer Excel, il faut faire une boucle et dans cette boucle mettre "DoEvents".
    Cordialement.

  5. #5
    Membre du Club
    Homme Profil pro
    Technicien d'usinage
    Inscrit en
    Juillet 2017
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Technicien d'usinage

    Informations forums :
    Inscription : Juillet 2017
    Messages : 132
    Points : 62
    Points
    62
    Par défaut
    Merci pour ta réponse je vais regarder un peu plus en détail car je ne m'y connais absolument pas en boucle

    mais merci de m'avoir orienté

  6. #6

  7. #7
    Expert éminent
    Avatar de jurassic pork
    Homme Profil pro
    Bidouilleur
    Inscrit en
    Décembre 2008
    Messages
    3 951
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Bidouilleur
    Secteur : Industrie

    Informations forums :
    Inscription : Décembre 2008
    Messages : 3 951
    Points : 9 280
    Points
    9 280
    Par défaut
    hello,
    sinon tu peux utiliser le contrôle Windows Media Player avec une playlist :
    1 - Insérer un Contrôles ActiveX/Autres contrôles/Windows Media Player dans une feuille excel . Mettre la propriété Visible à faux si on ne veut pas le voir.
    2 - Voici un exemple de code pour jouer deux fichiers (à mettre dans le code VBA de la feuille où se trouve le contrôle WMP) :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    Sub JoueSons()
    Dim media As Object
    WindowsMediaPlayer1.currentPlaylist.Clear
    Set media = WindowsMediaPlayer1.newMedia("D:\Temp\sons\Cochon1.mp3")
    WindowsMediaPlayer1.currentPlaylist.appendItem media
    Set media = WindowsMediaPlayer1.newMedia("D:\Temp\sons\Cochon2.mp3")
    WindowsMediaPlayer1.currentPlaylist.appendItem media
    WindowsMediaPlayer1.Controls.Play
    End Sub

    Ami calmant, J.P
    Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

  8. #8
    Membre du Club
    Homme Profil pro
    Technicien d'usinage
    Inscrit en
    Juillet 2017
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Technicien d'usinage

    Informations forums :
    Inscription : Juillet 2017
    Messages : 132
    Points : 62
    Points
    62
    Par défaut
    Merci à vous pour vos réponse

    Je suis parti sur une boucle que j'ai trouver intéressante poster par @LeForestier

    https://www.developpez.net/forums/d8...tion-wait-vba/

    Je vous remercie de votre aide !

    Cordialement

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 7
    Dernier message: 17/03/2016, 18h20
  2. [XL-2013] "Excel ne répond plus"
    Par bemax dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 05/10/2015, 17h00
  3. Mise en page graphique EXCEL via VBA Excel ne répond plus !
    Par Globetruck dans le forum Macros et VBA Excel
    Réponses: 14
    Dernier message: 30/06/2015, 17h48
  4. [XL-2003] Excel ne répond plus durant création graphiques
    Par Kaya_VB_13 dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 04/08/2013, 11h49
  5. [WD-2003] macro word lancée par excel ne répond pas correctement
    Par QuestVba dans le forum VBA Word
    Réponses: 8
    Dernier message: 12/07/2012, 13h32

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo