How to insert picture into text box?
By default, we can insert a picture or image into a worksheet as quickly by using the Insert function, but, this feature is not applied to inserting a picture into a textbox. With this article, I can help you to insert a picture into a textbox as you need.
To insert a picture into a textbox, the following VBA code may help you, please do as this:
1. Insert a textbox by clicking Insert > Text Box, and then draw a textbox, see screenshot:
2. Then hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.
3. Click Insert > Module, and paste the following code in the Module Window.
VBA code: Insert a picture into text box:
Sub ShapePicture() Dim xSh As Shape Dim xPic As IPictureDisp Dim xFileName As String xFileName = "C:\Users\DT168\Desktop\pictures\Apple.JPG" Set xPic = LoadPicture(xFileName) Set xSh = Sheets("Sheet4").Shapes(1) xSh.Height = xPic.Height / xPic.Width * xSh.Width Set xPic = LoadPicture("") Set xPic = Nothing xSh.Fill.UserPicture xFileName End Sub
Note: In the above code, Sheet4 is the sheet name which contains the text box you want to insert picture, and C:\Users\DT168\Desktop\pictures\Apple.JPG is the picture path of the picture you want to insert, you should change them to your need.
4. And then press F5 key to run this code, the specific image will be inserted into the text box at once, and you can edit the textbox as you need, see screenshot: