AnnaB
-
29 avril 2019 à 10:38
cs_Le Pivert
Messages postés7903Date d'inscriptionjeudi 13 septembre 2007StatutContributeurDernière intervention11 mars 2024
-
29 avril 2019 à 11:05
Bonjour,
Je me suis basé sur un code pour pouvoir recherché des images dans un fichier situé sur mon bureau "Chloé pour Anna". J'aimerais avoir mes photos dans la 1er colonne de mon excel où la référence de mon image se situe dans le 2e colonne. Cependant, lorsque je lance la macro, aucune photo n'apparaît. Quelqu'un pourrait il m'aider ? J'ai vraiment besoin d'illustrer dans un fichier excel les références des produits.
Voici le code:
Sub Foto_con_cat()
'
' Macro1 Macro
' Macro registrata il 27/06/2007 da Salvatore Ferragamo S.p.A.
'
Dim rigin, rigfi, ESISTE, gino, colin, colfi, gamma, delta 'j'ai sup ind, mioc, part
rigin = CInt(InputBox("Première ligne du tableau"))
rigfi = CInt(InputBox("Dernière ligne du tableau"))
colin = CInt(InputBox("Colonne du SKU - en chiffre"))
colfi = CInt(InputBox("Colonne Image - en chiffre"))
gamma = CInt(InputBox("Largeur de la colonne"))
delta = CInt(InputBox("Longueur de la colonne"))
gino = CInt(InputBox("SCHIZZO DOPO QUANTE RIGHE? 0=stessa riga 1=nella riga sotto"))
Dim I
Dim alfa As String
For I = rigin To rigfi Step 1
pippo = Cells(I, colin).Value 'cells (row, column) donne une valeur; insérer une valeur
If pippo <> 0 Then 'si la column SKU est différente de 0 alors
alfa = Right("00000000" & Cells(I, colin).Text, 8) 'right = donne le nombre de caractère à droite d'une chaine (chaine, nombre de caractères à droite)
iota = Mid(alfa, 1, 8) 'mid = nombre de caractères spécifiés à prendre (chaîne, position, nombre à prendre)
Cells(I + gino, colfi).Select 'sélectionner une valeur
beta = "I" + iota + ".JPG"
'ESISTE = (Dir(beta) <> "") 'renvoie une valeur STRING qui représente le nom du fichier correspondant à une chaine de recherche
ESISTE = Dir(beta)
If ESISTE = True Then
ActiveSheet.Pictures.Insert(beta).Select
Selection.Width = gamma
Selection.Height = delta
Selection.Border.LineStyle = xlNone
'Else
'Cells(I + 1, colfi) = "NO photo!"
End If
End If
'End If
Next I
ChDrive "C"
ChDir "C:\"
End Sub
Sub Foto_Senza_Categoria()
Dim rigin, rigfi, ESISTE, ind, mioc, part, gino, collin, colfi, gamma, delta
Dim iota As String
rigin = CInt(InputBox("Première ligne du tableau"))
rigfi = CInt(InputBox("Dernière ligne du tableau"))
colin = CInt(InputBox("Colonne du SKU - en chiffre"))
colfi = CInt(InputBox("Colonne Image - en chiffre"))
gamma = CInt(InputBox("Largeur de la colonne"))
delta = CInt(InputBox("Longueur de la colonne"))
gino = CInt(InputBox("SCHIZZO DOPO QUANTE RIGHE? 0=stessa riga 1=nella riga sotto"))
Dim I
Dim alfa As String
For I = rigin To rigfi Step 1
pippo = Cells(I, colin).Value
'If IsNumeric(pippo) Then
If pippo <> 0 Then
alfa = Format(Cells(I, colin).Value, ["00000000"]) 'renvoie une expression (Cells(I, colin).Value sous la forme d'un nombre
Cells(I + gino, colfi).Select
'ancien code : beta = "Z:\HBCD_Coldrerio\Shoes and LA Woman\000_Sharing Folder SHOandLA Woman\07_Style Pictures\02_Miniatures\" + alfa + ".JPG"
beta = "C:\Users\aboratynska\Desktop\CHLOE POUR ANNA" + alpha + ".JPG"
'ancien code : beta = "/Volumes/data/PHOTOS COLLECTIONS/" + alfa + ".JPG"
'ESISTE = (Dir(beta) <> "")
ESISTE = Dir(beta)
If ESISTE = True Then
ActiveSheet.Pictures.Insert(beta).Select
Selection.Width = gamma
Selection.Height = delta
'Selection.Border.LineStyle = xlNone
Selection.ShapeRange.Line.Visible = msoFalse
'Else
'Cells(I + 1, colfi) = "NO photo!"
End If
End If
'End If
Next I
' ChDrive "C"
' ChDir "C:\"
End Sub
Sub macro_photo_balmain_version_mac()
Dim rigin, rigfi, ESISTE, ind, mioc, part, gino, collin, colfi, gamma, delta
Dim iota As String
rigin = CInt(InputBox("Première ligne du tableau"))
rigfi = CInt(InputBox("Dernière ligne du tableau"))
colin = CInt(InputBox("Colonne du SKU - en chiffre"))
colfi = CInt(InputBox("Colonne Image - en chiffre"))
gamma = CInt(InputBox("Largeur de la colonne"))
delta = CInt(InputBox("Longueur de la colonne"))
gino = CInt(InputBox("SCHIZZO DOPO QUANTE RIGHE? 0=stessa riga 1=nella riga sotto"))
Dim I
Dim alfa As String
Dim tabPath() As String
Dim sizeTabPath As Long
sizeTabPath = 0
For I = rigin To rigfi Step 1
pippo = Cells(I, colin).Value
If pippo <> 0 Then
alfa = Format(Cells(I, colin).Value, ["00000000"])
' ancien code : beta = "/Volumes/data/communs/PHOTOS COLLECTIONS/" + alfa + ".JPG"
beta = "C:\Users\aboratynska\Desktop\CHLOE POUR ANNA" + alpha + ".JPG"
'If IsNumeric(pippo) Then
If pippo <> 0 Then
alfa = Format(Cells(I, colin).Value, ["00000000"])
Cells(I + gino, colfi).Select
'ancien code : beta = "Z:\HBCD_Coldrerio\Shoes and LA Woman\000_Sharing Folder SHOandLA Woman\07_Style Pictures\02_Miniatures\" + alfa + ".JPG"
' ancien code : beta = "/Volumes/data/communs/PHOTOS COLLECTIONS/" + alfa + ".JPG"
beta = "C:\Users\aboratynska\Desktop\CHLOE POUR ANNA" + alpha + ".JPG"
'ESISTE = (Dir(beta) <> "")
ESISTE = Dir(beta)
If ESISTE = True Then
ActiveSheet.Pictures.Insert(beta).Select
Selection.Width = gamma
Selection.Height = delta
'Selection.Border.LineStyle = xlNone
Selection.ShapeRange.Line.Visible = msoFalse
'Else
'Cells(I + 1, colfi) = "NO photo!"
End If
End If
'End If
Next I
' ChDrive "C"
'ChDir "C:\"
End Sub
Sub macro_photo_balmain_version_pc()
Dim rigin, rigfi, ESISTE, ind, mioc, part, gino, collin, colfi, gamma, delta
Dim iota As String
rigin = CInt(InputBox("Première ligne du tableau"))
rigfi = CInt(InputBox("Dernière ligne du tableau"))
colin = CInt(InputBox("Colonne du SKU - en chiffre"))
colfi = CInt(InputBox("Colonne Image - en chiffre"))
gamma = CInt(InputBox("Largeur de la colonne"))
delta = CInt(InputBox("Longueur de la colonne"))
gino = CInt(InputBox("SCHIZZO DOPO QUANTE RIGHE? 0=stessa riga 1=nella riga sotto"))
Dim I
Dim alfa As String
For I = rigin To rigfi Step 1
pippo = Cells(I, colin).Value
'If IsNumeric(pippo) Then
If pippo <> 0 Then
alfa = Format(Cells(I, colin).Value, ["00000000"])
Cells(I + gino, colfi).Select
'ancien code : beta = "Z:\HBCD_Coldrerio\Shoes and LA Woman\000_Sharing Folder SHOandLA Woman\07_Style Pictures\02_Miniatures\" + alfa + ".JPG"
'ancien code : beta = "X:\PHOTOS COLLECTIONS\" + alfa + ".JPG"
beta = "C:\Users\aboratynska\Desktop\CHLOE POUR ANNA" + alpha + ".JPG"
' ESISTE = (Dir(beta) <> "")
ESISTE = Dir(beta)
If ESISTE = True Then
ActiveSheet.Pictures.Insert(beta).Select
Selection.Width = gamma
Selection.Height = delta
Selection.Border.LineStyle = xlNone
'Selection.ShapeRange.Line.Visible = msoFalse
'Else
'Cells(I + 1, colfi) = "NO photo!"
End If
End If
'End If
Next I