kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
Hello again,
I am yet into another trouble and I want someone pull me out:
My image control is not switching its images when I use the loop to print. It maintains only the first image throughout .
So if the first item has no image, then it takes that for all the others.
Meanwhile when I select the items one by one from the listbox on the userform , it switches the images.
I have tried to enable screen updating and events. Also set the calculations to automatic yet it's not cool.
What is going wrong?
I am yet into another trouble and I want someone pull me out:
My image control is not switching its images when I use the loop to print. It maintains only the first image throughout .
So if the first item has no image, then it takes that for all the others.
Meanwhile when I select the items one by one from the listbox on the userform , it switches the images.
I have tried to enable screen updating and events. Also set the calculations to automatic yet it's not cool.
What is going wrong?
Code:
Private Sub CmdPrintAll ()
Dim i As Long
With Sheet1
For i = 1 To 25
. [G4] = i
. [E3] = Application.VLookup (. [G4], Sheet2. [B2:F202], 2, False )
. [E7] = Application.VLookup (. [G4], Sheet2. [B2:F202], 3, False )
Next i
End With
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Target = Me.[E3] Or Target = Me.[E7] Then
Select Case Target.Address
Case Is = "$E$3"
LoadIm "Image1", Me.[E3], [COLOR=#0000ff]"Passport"[/COLOR]
Case Is = "$E$7"
LoadIm "Image2", Me.[E7], [COLOR=#0000ff]"Signature[/COLOR]"
End Select
End If
End Sub
Sub LoadIm(cname$, r As Range, [COLOR=#0000ff]folder As String[/COLOR])
Dim fpath$, sfile$
fpath = ThisWorkbook.Path &[COLOR=#0000ff] "\" & folder[/COLOR]
sfile = Dir(fpath & "\" & r.Text & ".*")
If sfile <> vbNullString Then
Me.OLEObjects(cname).Object.Picture = LoadPicture(fpath & "\" & sfile)
Else
Me.OLEObjects(cname).Object.Picture = LoadPicture("")
End If
If Err.Number = 53 Then Me.OLEObjects(cname).Object.Picture = LoadPicture("")
End Sub