letrolldu27
New Member
- Joined
- Sep 25, 2016
- Messages
- 6
Hello forum
I put my problem
An array A to E
A = Name (TextBox1)
B = Line number (TextBox2)
C = Image Path (Lbl_Image)
D = Image name (Image1)
If E = No Image
I wish I built this in the code below di *
if TextBox1 column A2: A has no pictures in the paper "Images" of his assigned location of the column D2: D
then load the logo "Image1" of UserForm1 in the sheet "Images" location E2: E5 be the name "Pas_Images"
I put my problem
An array A to E
A = Name (TextBox1)
B = Line number (TextBox2)
C = Image Path (Lbl_Image)
D = Image name (Image1)
If E = No Image
I wish I built this in the code below di *
if TextBox1 column A2: A has no pictures in the paper "Images" of his assigned location of the column D2: D
then load the logo "Image1" of UserForm1 in the sheet "Images" location E2: E5 be the name "Pas_Images"
Code:
[FONT=Courier New][COLOR=#2600ff][B]Private[/B][/COLOR] [COLOR=#2600ff][B]Sub[/B][/COLOR] CmdB_Ouvrir_Image_Click() [/FONT][FONT=Courier New][COLOR=#008000]' Utiliser la propriété LoadPicture avec GetOpenFilename Méthode pour charger l'image à un contrôle d'image.
[/COLOR]
[COLOR=#2600ff][B] Dim[/B][/COLOR] strFltr [COLOR=#2600ff][B]As[/B][/COLOR] [COLOR=#2600ff][B]String[/B][/COLOR], strTtl [COLOR=#2600ff][B]As[/B][/COLOR] [COLOR=#2600ff][B]String[/B][/COLOR], strFileName [COLOR=#2600ff][B]As[/B][/COLOR] [COLOR=#2600ff][B]String[/B][/COLOR]
[COLOR=#2600ff][B] Dim[/B][/COLOR] iFltrIndx [COLOR=#2600ff][B]As[/B][/COLOR] [COLOR=#2600ff][B]Integer[/B][/COLOR], derlign [COLOR=#2600ff][B]As[/B][/COLOR] [COLOR=#2600ff][B]Integer[/B][/COLOR]
[COLOR=#2600ff][B] Dim[/B][/COLOR] bMltiSlct [COLOR=#2600ff][B]As[/B][/COLOR] [COLOR=#2600ff][B]Boolean[/B][/COLOR]
[COLOR=#2600ff][B] Set[/B][/COLOR] Wsi = Sheets([COLOR=#800000]"Images"[/COLOR]) [/FONT][FONT=Courier New][COLOR=#008000]' Valeur de consigne pour les variables à utiliser dans GetOpenFilename Méthode[/COLOR]
strFltr = [COLOR=#800000]"Tiff (*.tif;*.tiff),*.tif;*.tiff,JPEG (*.jpg;*.jpeg;*.jfif;*.jpe),*.jpg;*.jpeg;*.jfif;*.jpe,Bitmap (*.bmp),*.bmp")[/COLOR]
iFltrIndx = 2
strTtl = [COLOR=#800000]"Sélectionnez l'image du contact"[/COLOR]
bMltiSlct = [COLOR=#2600ff][B]False[/B][/COLOR] [/FONT][FONT=Courier New][COLOR=#008000]' Déclaration ChDrive définit le lecteur en cours à C
[/COLOR]
ChDrive [COLOR=#800000]"C"[/COLOR] [/FONT][FONT=Courier New][COLOR=#008000]' Déclaration ChDir définit le répertoire courant C:\Users\Public\Pictures\
[/COLOR]
ChDir [COLOR=#800000]"C:\Users\Public\Pictures\"[/COLOR] [/FONT][FONT=Courier New][COLOR=#008000]' Utiliser GetOpenFilename Méthode pour sélectionner l'image: Logo
[/COLOR]
strFileName = Application.GetOpenFilename(strFltr, iFltrIndx, strTtl, , bMltiSlct)
[COLOR=#2600ff][B]
On[/B][/COLOR] [COLOR=#2600ff][B]Error[/B][/COLOR] [COLOR=#2600ff][B]Resume[/B][/COLOR] [COLOR=#2600ff][B]Next[/B][/COLOR]
[COLOR=#2600ff][B] If[/B][/COLOR] strFileName <> [COLOR=#800000]"False"[/COLOR] [COLOR=#2600ff][B]Then[/B][/COLOR] [/FONT][FONT=Courier New][COLOR=#008000]' Charge image pour le contrôle de l'image, en utilisant la propriété LoadPicture[/COLOR] Me.Image1.Picture = LoadPicture(strFileName) [/FONT][FONT=Courier New][COLOR=#008000]' Après tout changement <acronym title="visual basic for applications">vba</acronym> doit être dit pour rafraîchir la UserForm pour que le changement semble[/COLOR]
Me.Repaint [/FONT][FONT=Courier New][COLOR=#008000]' Etiquette légende change après l'image est chargée[/COLOR]
Me.Lbl_Image.Caption = strFileName
[COLOR=#2600ff][B] Else[/B][/COLOR]
MsgBox [COLOR=#800000]"Pas d'image sélectionnez!"[/COLOR]
[COLOR=#2600ff][B] End[/B][/COLOR] [COLOR=#2600ff][B]If[/B][/COLOR] [/FONT][FONT=Courier New][COLOR=#008000]' gestionnaire d'erreurs reset[/COLOR]
[COLOR=#2600ff][B] On[/B][/COLOR] [COLOR=#2600ff][B]Error[/B][/COLOR] [COLOR=#2600ff][B]GoTo[/B][/COLOR] 0
[COLOR=#2600ff][B]End[/B][/COLOR] [COLOR=#2600ff][B]Sub[/B][/COLOR][/FONT]