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 :

conversion image via WIA erreur


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 374
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 374
    Billets dans le blog
    8
    Par défaut conversion image via WIA erreur
    Bonjour a tous
    j'essai de convertir une png en gif avec WIA mais j'ai un message d'erreur que je ne saisi pas
    j'ai beau chercher je ne trouve rien de concluant

    une idée?????
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    Sub transform2(chemin)
    Dim Img 'As ImageFile
    Set Img = CreateObject("WIA.ImageFile")
    Img.LoadFile chemin
    If Img.FormatID <> wiaFormatGIF Then
        Dim IP 'As New ImageProcess
        Set IP = CreateObject("Wia.ImageProcess")
     
        IP.Filters.Add IP.FilterInfos("Convert").FilterID
        IP.Filters(1).Properties("FormatID").Value = wiaFormatGIF
        Set Img = IP.Apply(Img)
    Img.SaveFile ThisWorkbook.Path & "\copie.gif"
    End If
    End Sub
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  2. #2
    Membre éclairé
    Homme Profil pro
    Constructeur ossature bois
    Inscrit en
    Mars 2014
    Messages
    897
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Constructeur ossature bois
    Secteur : Associations - ONG

    Informations forums :
    Inscription : Mars 2014
    Messages : 897
    Par défaut
    Salut Patrick,
    Bon après recherche, voici ce que j'ai trouvé, il faut déclarer des constantes de cette façon et après ça fonctionne, test à l'appui
    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
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    ' Miscellaneous
     
    Const wiaIDUnknown = "{00000000-0000-0000-0000-000000000000}"
    Const wiaAnyDeviceID = "*"
     
    ' FormatID
     
    Const wiaFormatBMP = "{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}"
    Const wiaFormatPNG = "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}"
    Const wiaFormatGIF = "{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}"
    Const wiaFormatJPEG = "{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"
    Const wiaFormatTIFF = "{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}"
     
    ' EventID
     
    Const wiaEventDeviceConnected = "{A28BBADE-64B6-11D2-A231-00C04FA31809}"
    Const wiaEventDeviceDisconnected = "{143E4E83-6497-11D2-A231-00C04FA31809}"
    Const wiaEventItemCreated = "{4C8F4EF5-E14F-11D2-B326-00C04F68CE61}"
    Const wiaEventItemDeleted = "{1D22A559-E14F-11D2-B326-00C04F68CE61}"
    Const wiaEventScanImage = "{A6C5A715-8C6E-11D2-977A-0000F87A926F}"
    Const wiaEventScanPrintImage = "{B441F425-8C6E-11D2-977A-0000F87A926F}"
    Const wiaEventScanFaxImage = "{C00EB793-8C6E-11D2-977A-0000F87A926F}"
    Const wiaEventScanOCRImage = "{9D095B89-37D6-4877-AFED-62A297DC6DBE}"
    Const wiaEventScanEmailImage = "{C686DCEE-54F2-419E-9A27-2FC7F2E98F9E}"
    Const wiaEventScanFilmImage = "{9B2B662C-6185-438C-B68B-E39EE25E71CB}"
    Const wiaEventScanImage2 = "{FC4767C1-C8B3-48A2-9CFA-2E90CB3D3590}"
    Const wiaEventScanImage3 = "{154E27BE-B617-4653-ACC5-0FD7BD4C65CE}"
    Const wiaEventScanImage4 = "{A65B704A-7F3C-4447-A75D-8A26DFCA1FDF}"
     
    ' CommandID
     
    Const wiaCommandSynchronize = "{9B26B7B2-ACAD-11D2-A093-00C04F72DC3C}"
    Const wiaCommandTakePicture = "{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}"
    Const wiaCommandDeleteAllItems = "{E208C170-ACAD-11D2-A093-00C04F72DC3C}"
    Const wiaCommandChangeDocument = "{04E725B0-ACAE-11D2-A093-00C04F72DC3C}"
    Const wiaCommandUnloadDocument = "{1F3B3D8E-ACAE-11D2-A093-00C04F72DC3C}"
     
    ' WiaSubType enumeration
     
    Const UnspecifiedSubType = 0
    Const RangeSubType = 1
    Const ListSubType = 2
    Const FlagSubType = 3
     
    ' WiaDeviceType enumeration
     
    Const UnspecifiedDeviceType = 0
    Const ScannerDeviceType = 1
    Const CameraDeviceType = 2
    Const VideoDeviceType = 3
     
    ' WiaItemFlag enumeration
     
    Const FreeItemFlag = &h0
    Const ImageItemFlag = &h1
    Const FileItemFlag = &h2
    Const FolderItemFlag = &h4
    Const RootItemFlag = &h8
    Const AnalyzeItemFlag = &h10
    Const AudioItemFlag = &h20
    Const DeviceItemFlag = &h40
    Const DeletedItemFlag = &h80
    Const DisconnectedItemFlag = &h100
    Const HPanoramaItemFlag = &h200
    Const VPanoramaItemFlag = &h400
    Const BurstItemFlag = &h800
    Const StorageItemFlag = &h1000
    Const TransferItemFlag = &h2000
    Const GeneratedItemFlag = &h4000
    Const HasAttachmentsItemFlag = &h8000
    Const VideoItemFlag = &h10000
    Const RemovedItemFlag = &h80000000
     
    ' WiaPropertyType enumeration
     
    Const UnsupportedPropertyType = 0
    Const BooleanPropertyType = 1
    Const BytePropertyType = 2
    Const IntegerPropertyType = 3
    Const UnsignedIntegerPropertyType = 4
    Const LongPropertyType = 5
    Const UnsignedLongPropertyType = 6
    Const ErrorCodePropertyType = 7
    Const LargeIntegerPropertyType = 8
    Const UnsignedLargeIntegerPropertyType = 9
    Const SinglePropertyType = 10
    Const DoublePropertyType = 11
    Const CurrencyPropertyType = 12
    Const DatePropertyType = 13
    Const FileTimePropertyType = 14
    Const ClassIDPropertyType = 15
    Const StringPropertyType = 16
    Const ObjectPropertyType = 17
    Const HandlePropertyType = 18
    Const VariantPropertyType = 19
    Const VectorOfBooleansPropertyType = 101
    Const VectorOfBytesPropertyType = 102
    Const VectorOfIntegersPropertyType = 103
    Const VectorOfUnsignedIntegersPropertyType = 104
    Const VectorOfLongsPropertyType = 105
    Const VectorOfUnsignedLongsPropertyType = 106
    Const VectorOfErrorCodesPropertyType = 107
    Const VectorOfLargeIntegersPropertyType = 108
    Const VectorOfUnsignedLargeIntegersPropertyType = 109
    Const VectorOfSinglesPropertyType = 110
    Const VectorOfDoublesPropertyType = 111
    Const VectorOfCurrenciesPropertyType = 112
    Const VectorOfDatesPropertyType = 113
    Const VectorOfFileTimesPropertyType = 114
    Const VectorOfClassIDsPropertyType = 115
    Const VectorOfStringsPropertyType = 116
    Const VectorOfVariantsPropertyType = 119
     
    ' WiaImagePropertyType enumeration
     
    Const UndefinedImagePropertyType = 1000
    Const ByteImagePropertyType = 1001
    Const StringImagePropertyType = 1002
    Const UnsignedIntegerImagePropertyType = 1003
    Const LongImagePropertyType = 1004
    Const UnsignedLongImagePropertyType = 1005
    Const RationalImagePropertyType = 1006
    Const UnsignedRationalImagePropertyType = 1007
    Const VectorOfUndefinedImagePropertyType = 1100
    Const VectorOfBytesImagePropertyType = 1101
    Const VectorOfUnsignedIntegersImagePropertyType = 1102
    Const VectorOfLongsImagePropertyType = 1103
    Const VectorOfUnsignedLongsImagePropertyType = 1104
    Const VectorOfRationalsImagePropertyType = 1105
    Const VectorOfUnsignedRationalsImagePropertyType = 1106
     
    ' WiaEventFlag enumeration
     
    Const NotificationEvent = 1
    Const ActionEvent = 2
     
    ' WiaImageIntent enumeration
     
    Const UnspecifiedIntent = 0
    Const ColorIntent = 1
    Const GrayscaleIntent = 2
    Const TextIntent = 4
     
    ' WiaImageBias enumeration
     
    Const MinimizeSize = 65536
    Const MaximizeQuality = 131072
    Evidemment tu ne déclares que celle dont tu as besoin

    ICI

    Seb

  3. #3
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 374
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 374
    Billets dans le blog
    8
    Par défaut re
    puré j'y crois pas c'est le bleu qui me met la patée
    bien vu seb
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  4. #4
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 374
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 374
    Billets dans le blog
    8
    Par défaut re
    bon maintenant j'ai un autre soucis
    la convertion transforme la transparence en blanc opaque et m'encadre en noir l image !!
    Nom : Capture.JPG
Affichages : 685
Taille : 18,3 Ko
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  5. #5
    Membre averti
    Homme Profil pro
    Data manager
    Inscrit en
    Janvier 2016
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France, Calvados (Basse Normandie)

    Informations professionnelles :
    Activité : Data manager
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Janvier 2016
    Messages : 20
    Par défaut
    Bonjour à vous deux,

    Je me suis également penché sur la petite colle de Patrick.

    J'ai essayé cela qui fonctionne chez moi :

    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
    Sub test_images2()
     
    'Microsoft Windows Image Acquisition Library v2.0
     
     
    Dim Img 'As ImageFile
    Dim IP 'As ImageProcess
     
    Set Img = CreateObject("WIA.ImageFile")
    Set IP = CreateObject("WIA.ImageProcess")
     
    Img.LoadFile "Tonchemin\banane.png"
     
    IP.Filters.Add IP.FilterInfos("Convert").FilterID
    IP.Filters(1).Properties("FormatID").Value = wiaFormatGIF
    IP.Filters(1).Properties("Quality").Value = 5
     
    Set Img = IP.Apply(Img)
     
    Img.SaveFile "TonChemin\banane_conversion.gif"
     
    End Sub
    Au plaisir

    Cdt

  6. #6
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 374
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 374
    Billets dans le blog
    8
    Par défaut re
    Bonjour OlivYeah
    c'est exactement mon premier code qui ne fonctionne pas chez moi
    tu tourne sur quoi comme system d'exploitation ??
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  7. #7
    Membre averti
    Homme Profil pro
    Data manager
    Inscrit en
    Janvier 2016
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France, Calvados (Basse Normandie)

    Informations professionnelles :
    Activité : Data manager
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Janvier 2016
    Messages : 20
    Par défaut
    Patrick,

    Oui exactement, c'est pour cela que j'étais un peu surpris.

    Au premier essai j'avais le message d'erreur comme quoi l'ID était mal formaté.
    J'ai uniquement ajouté la ligne relative à la qualité, tapé le chemin en dur et activé la référence.

    Je t'avoue que je ne comprends pas trop ...

    Je tourne sous Windows 7 Pro 64, SP1
    Office 2013

    Bien cordialement

    Olivier

  8. #8
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 374
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 374
    Billets dans le blog
    8
    Par défaut re
    et est ce que ca te vire la transparence aussi chez toi???
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  9. #9
    Membre éclairé
    Homme Profil pro
    Constructeur ossature bois
    Inscrit en
    Mars 2014
    Messages
    897
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Constructeur ossature bois
    Secteur : Associations - ONG

    Informations forums :
    Inscription : Mars 2014
    Messages : 897
    Par défaut
    Re,

    puré j'y crois pas c'est le bleu qui me met la patée
    bon bon ça va....

    Chez moi pas de problème comme tu peux le voir.
    Nom : 2016-02-09_15-40-12.jpg
Affichages : 586
Taille : 7,5 Ko

    Mais...je regarde s'il y a pas une autre propriété au cas où
    seb

  10. #10
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 374
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 374
    Billets dans le blog
    8
    Par défaut
    Citation Envoyé par Sebphyto Voir le message
    Re,


    bon bon ça va....

    Chez moi pas de problème comme tu peux le voir.


    Mais...je regarde s'il y a pas une autre propriété au cas où
    seb
    ok mais c'est bien que tu apporte un peu ton aide ca change
    toi aussi essaie de convertir un png avec transparence pour voir
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  11. #11
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 374
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 374
    Billets dans le blog
    8
    Par défaut re
    bon en effet je viens de faire le teste il semblerait qu' en LateBinding tout ne soit pas pris en compte allez savoir !!!

    donc même avec les variable en declaration tardives
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    Dim Img 'As object
    Dim IP 'As object
    Set Img = CreateObject("WIA.ImageFile")
    Set IP = CreateObject("WIA.ImageProcess")
    activez quand même la référence Microsoft Windows Image Aquisition version(X,Y)
    et la!!.. même avec les constantes bloquées ca fonctionne

    Merci OlivYeah c'est toi qui m'a mis la puce a l'oreille

    bon maintenant toujour ce soucis de transparence
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  12. #12
    Membre averti
    Homme Profil pro
    Data manager
    Inscrit en
    Janvier 2016
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France, Calvados (Basse Normandie)

    Informations professionnelles :
    Activité : Data manager
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Janvier 2016
    Messages : 20
    Par défaut
    Re à vous deux,

    Patrick, j'ose te dire "de rien", du haut de ma petite contribution, vu le nombre de posts et de contributions laissés de ta part sur ce forum

    Je suis aussi sur la transparence pour test.

Discussions similaires

  1. Ouverture d'une image via un script PHP
    Par passie dans le forum PostgreSQL
    Réponses: 3
    Dernier message: 24/01/2006, 17h10
  2. Problème de récup image via http://
    Par TK5EP dans le forum Langage
    Réponses: 3
    Dernier message: 26/12/2005, 19h59
  3. [Image]Conversion Image en byte[] ou BufferedImage en byte[]
    Par ¤ Actarus ¤ dans le forum Entrée/Sortie
    Réponses: 6
    Dernier message: 11/12/2005, 22h46
  4. Réponses: 1
    Dernier message: 31/10/2005, 09h33
  5. [HTTP] Passage d'image via la methode post
    Par muldoon dans le forum Entrée/Sortie
    Réponses: 2
    Dernier message: 26/05/2005, 09h05

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