How to insert a picture in multiple worksheets automatically with VBA.
A user has multiple sheets in a workbook as tax invoice, original for recipient, duplicate for transport, triplicate for Supplier, an extra copy for records, an estimate sheet, proforma invoice sheet and also a worksheet called Info. When he places a logo in the Info sheet in a specific cell it should be replaced with the existing logo in all sheets. Watch the video below to see how an automatic solution to the problem has been achieved using VBA:
Watch this video on YouTube.
Here’s the complete VBA code to insert a logo automatically in many worksheets simultaneously:
Dim myPicture As Variant
Dim p As Object
myPicture = Application.GetOpenFilename(“Pictures(*.gif;*.jpg;*.bmp;*.tif),*.gif;*.jpg;*.bmp;*.tif”, , “Select Picture to Import”)
If myPicture = False Then Exit Sub
For Each Sheet In Sheets
On Error Resume Next
Set p = ActiveSheet.Pictures.Insert(myPicture)
Set myObj = ActiveSheet.DrawingObjects
For Each Pictur In myObj
If Left(Pictur.Name, 7) = “Picture” Then
Download a sample file for practice: