Mở Excel , bấm tổ hợp Alt-F11 để vào cửa sổ Microsoft Visual Basic .
Chọn menu Insert > Module , bạn copy nội dung chữ đậm bên dưới
Sub AddPic()
Dim myPicture As Variant
Dim p As Object
Dim Factor As Single
myPicture = Application.GetOpenFilename _
(\"Pictures (*.gif; *.cgm; *.jpg; *.bmp; *.tif),*.gif; *.cgm; *.jpg; *.bmp; *.tif\", , \"Select Picture to Import\")
If myPicture = False Then Exit Sub
For Each Page In Sheets
Page.Activate
Range(\"B2\").Select
Set p = ActiveSheet.Pictures.Insert(myPicture)
’Width and Height are in points (1/72 inch)
p.ShapeRange.LockAspectRatio = msoTrue
Hfactor = 5 / (p.Height / 72)
Wfactor = 5.69 / (p.Width / 72)
If Hfactor < Wfactor Then
Factor = Hfactor
Else
Factor = Wfactor
End If
p.Width = p.Width * Factor
p.Height = p.Height * Factor
Next
End Sub
B2 là vị trí của bức ảnh sẽ đặt .
Hfactor và Wfactor là kích thước của bức ảnh .
Quay trở lại Excel .
Nếu bạn dùng Office 2007 trở lên , chọn tab Developer > Macro rồi chạy macro có tên là AddPic
Nếu dùng Office 2003 , chọn Tools > Macro > Macros