Hi mọi người,
Mình có đoạn code cần giúp đỡ trong form,
Có cách nào thây đổi đường dẫn hình ảnh trong file đính kèm về ổ D:/ được ko vậy? Mọi người xem file đính kèm giúp mình với
Private ScrWidth&, ScrHeight&
Private Declare Function GetSystemMetrics32 Lib "User32" _
Alias "GetSystemMetrics" (ByVal nIndex&) As Long
Private Sub UserForm_Initialize()
Dim Factor As Single
Factor = 0.75 'adjust to suit
Me.Width = GetSystemMetrics32(0) Factor '< in pixels
Me.Height = GetSystemMetrics32(1) Factor
LoadPic
'old
'Me.Height = Application.UsableHeight
'Me.Width = Application.UsableWidth - 1
End Sub
Private Sub LoadPic()
Dim imgFolder As String
Dim sFileName As String
On Error GoTo Thoat
'get the path to the images
' Khúc Này cần mọi người giúp đỡ nè
imgFolder = ThisWorkbook.Path & Application.PathSeparator & "images" & Application.PathSeparator
sFileName = Range("F" & ActiveCell.Row).Value
With Me
.Image1.Picture = LoadPicture(imgFolder & sFileName & ".jpg") 'load picture to form
.Image1.Left = .Width / 2 - .Image1.Width / 2
.Caption = "Address: " & imgFolder & sFileName & ".jpg"
End With
Exit Sub
Thoat:
'MsgBox ("Ko tim thay' Pic") & sFileName, vbExclamation
End Sub
Private Sub UserForm_Click()
Unload Me
End Sub
Private Sub Image1_Click()
Unload Me
End Sub