Thầy ơi! cho em hỏi: Em muốn chèn ảnh vào ô, khi em thay đổi ô chọn (ô active khác) thì sự kiện chèn ảnh hiện ra (hiện hộp thoại chèn ảnh để lựa chọn ảnh để chèn) thì em Phải làm sau hả Thầy?
Sub InsertPicUsingInsertFunction()
Dim profile As String
On Error GoTo 0
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.Filters.Clear
.Filters.Add "Picture Files", "*.bmp;*.jpg;*.gif;*.png"
.ButtonName = "Select"
.AllowMultiSelect = False
.Title = "Choose Photo"
.InitialView = msoFileDialogViewDetails
.Show
End With
With ActiveSheet.Pictures.Insert(fd.SelectedItems(1))
.Left = ActiveSheet.Range("B2").Left + 2
.Top = ActiveSheet.Range("B2").Top + 2
.Placement = 1
.PrintObject = True
profile = .Name
End With
ActiveSheet.Pictures(profile).Select
With Selection.ShapeRange
.LockAspectRatio = msoFalse
.Width = 123
.Height = 134
End With
End Sub
mong thầy giúp đỡ, Đoạn code trên chỉ chèn vào 1 ô B2 thui, Cảm ơn thầy