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 :

Lire l'ID Produit par Macro


Sujet :

Macros et VBA Excel

  1. #1
    Membre habitué
    Profil pro
    Inscrit en
    Août 2007
    Messages
    684
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 684
    Points : 153
    Points
    153
    Par défaut Lire l'ID Produit par Macro
    Bonjour,

    Je voudrais par Macro pouvoir lire
    L'ID du Produit Excel
    Ceci a des fins d'identification.

    Je me tourne vers vous n'ayant rien trouvé sur le Net.

    Merci à vous

  2. #2
    Expert éminent
    Avatar de fring
    Homme Profil pro
    Engineering
    Inscrit en
    Février 2008
    Messages
    3 900
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 60
    Localisation : Belgique

    Informations professionnelles :
    Activité : Engineering

    Informations forums :
    Inscription : Février 2008
    Messages : 3 900
    Points : 7 964
    Points
    7 964
    Par défaut
    Bonjour,

    Ceci ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Application.ProductCode
    LES FAQ OFFICE - LES COURS OFFICE - LES COURS EXCEL - LES LIVRES OFFICE - SOURCES VBA - ATELIER BRICOLAGE VBA

    Lorsque votre problème est solutionné, pensez à le signaler en cliquant sur le bouton au bas de la discussion.

  3. #3
    Membre habitué
    Profil pro
    Inscrit en
    Août 2007
    Messages
    684
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 684
    Points : 153
    Points
    153
    Par défaut
    Merci de m'avoir répondu,

    Je récupère bien un code, mais je ne sait
    pas a quoi il correspond !

    Dans Excel quand on fait en haut :

    ? + A propos, cela affiche Licence d'utilisation accordée a :

    Et c'est la que ce trouve L'ID du Produit
    Ce que je veut récupérer

  4. #4
    Expert éminent sénior
    Avatar de kiki29
    Homme Profil pro
    ex Observeur CGG / Analyste prog.
    Inscrit en
    Juin 2006
    Messages
    6 132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : ex Observeur CGG / Analyste prog.

    Informations forums :
    Inscription : Juin 2006
    Messages : 6 132
    Points : 11 274
    Points
    11 274
    Par défaut
    Salut, à priori Il faut aller le chercher dans la base de registre
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\XX.0\Registration\{91...-00..  }  ProductID
    ou XX.0 correspondant à la version d'Excel donnée par Application.Version
    et {91...-..00..} est le Application.ProductCode donné par Fring plus haut

  5. #5
    Membre habitué
    Profil pro
    Inscrit en
    Août 2007
    Messages
    684
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 684
    Points : 153
    Points
    153
    Par défaut
    Ok,

    Par Regedit avec le chemin + le Application.ProductCode,

    Je récupère bien l'ID du Produit.

    Maintenant comment le récupérer par la Macro ?

  6. #6
    Membre émérite Avatar de Godzestla
    Homme Profil pro
    Chercheur de bonheur
    Inscrit en
    Août 2007
    Messages
    2 392
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 59
    Localisation : Belgique

    Informations professionnelles :
    Activité : Chercheur de bonheur
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2007
    Messages : 2 392
    Points : 2 985
    Points
    2 985
    Par défaut
    Salut,

    voici un exemple pour lire dans la registry.

    Tu pourras adapter en fonction de tes besoins

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
    Ghoscript_Key = "HKEY_LOCAL_MACHINE\SOFTWARE\GPL Ghostscript\" & Left$(sName, ret) & "\" & "GS_DLL"
     
    'Read Ghoscript Key
    Set objWSH = CreateObject("WScript.Shell")
     
     
    On Error Resume Next
     gs_pkg = objWSH.RegRead(Ghoscript_Key)
     If Err.Number <> 0 Then
         MsgBox "Key """ & Ghoscript_Key & """ not inside the registry."
         gs_pkg = Null
     End If
     On Error GoTo 0
    (\ _ /) Cordialement G@dz
    (='.'=)

    (")-(") Vous avez des neurones. Sollicitez-les. . Si vous êtes aidé, pensez à Voter.

  7. #7
    Membre habitué
    Profil pro
    Inscrit en
    Août 2007
    Messages
    684
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 684
    Points : 153
    Points
    153
    Par défaut
    voici ma chaine :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    Ghoscript_Key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Registration\{9011040C-6000-11D3-8CFE-0150048383C9}  PruductID" & Left$(sName, ret) & "\" & "GS_DLL"
    Le msgbox m'affiche :
    Key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Registration\{9011040C-6000-11D3-8CFE-0150048383C9} PruductID" & Left$(sName, ret) & "\" & "GS_DLL"not inside the registry.

    Et je ne récupère pas le ProductID ?

  8. #8
    Expert éminent sénior
    Avatar de kiki29
    Homme Profil pro
    ex Observeur CGG / Analyste prog.
    Inscrit en
    Juin 2006
    Messages
    6 132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : ex Observeur CGG / Analyste prog.

    Informations forums :
    Inscription : Juin 2006
    Messages : 6 132
    Points : 11 274
    Points
    11 274
    Par défaut
    Salut, relis ton code et comprends celui de Godzestla : c'est normal qu'il ne lise pas le ProductID....
    adapté de Godzestla

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
     
    Option Explicit
     
    Sub Tst()
    Dim Vers As String
    Dim oWsh As Object
    Dim Cle As String, CleReg As String
    Dim Prod As String
     
        Vers = Application.Version
        Prod = Application.ProductCode
     
        CleReg = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\" & Vers & "\Registration\" & Prod & "\ProductID"
     
        Set oWsh = CreateObject("WScript.Shell")
     
        On Error Resume Next
        Cle = oWsh.RegRead(CleReg)
     
        If Err.Number <> 0 Then
            MsgBox "Clé " & CleReg & " absente du registre."
            Set oWsh = Nothing
            Exit Sub
        End If
        On Error GoTo 0
     
        Set oWsh = Nothing
        MsgBox Cle
    End Sub

  9. #9
    Membre émérite Avatar de Godzestla
    Homme Profil pro
    Chercheur de bonheur
    Inscrit en
    Août 2007
    Messages
    2 392
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 59
    Localisation : Belgique

    Informations professionnelles :
    Activité : Chercheur de bonheur
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2007
    Messages : 2 392
    Points : 2 985
    Points
    2 985
    Par défaut
    Merci Kiki29
    (\ _ /) Cordialement G@dz
    (='.'=)

    (")-(") Vous avez des neurones. Sollicitez-les. . Si vous êtes aidé, pensez à Voter.

  10. #10
    Membre habitué
    Profil pro
    Inscrit en
    Août 2007
    Messages
    684
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 684
    Points : 153
    Points
    153
    Par défaut
    Salut kiki29,

    Super merci, le dernier code tourne parfaitement

    et c'est exactement ce que je souhaitais

    Grace a vous tous, j'ai bien avancé

    Encore merci

    @ +

  11. #11
    Membre émérite Avatar de Godzestla
    Homme Profil pro
    Chercheur de bonheur
    Inscrit en
    Août 2007
    Messages
    2 392
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 59
    Localisation : Belgique

    Informations professionnelles :
    Activité : Chercheur de bonheur
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2007
    Messages : 2 392
    Points : 2 985
    Points
    2 985
    Par défaut
    Avec plaisir.
    (\ _ /) Cordialement G@dz
    (='.'=)

    (")-(") Vous avez des neurones. Sollicitez-les. . Si vous êtes aidé, pensez à Voter.

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

Discussions similaires

  1. Créer et lire un fichier wav par macro
    Par fred65200 dans le forum Contribuez
    Réponses: 0
    Dernier message: 30/01/2009, 19h40
  2. Excel:probleme pour transformer du texte en nombre par macro
    Par pcheval dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 09/11/2005, 22h18
  3. Lire un fichier txt par http (C sous Linux)
    Par sleg dans le forum Réseau
    Réponses: 4
    Dernier message: 18/10/2005, 11h07
  4. lire un fichier ligne par ligne
    Par peuf23 dans le forum C
    Réponses: 6
    Dernier message: 21/09/2005, 10h43

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