Add background image to textbox

MarkOW

New Member
Joined
Jun 26, 2018
Messages
35
Can anyone show how to add an image fill to the textbox I have inserted into a worksheet please.

Code:
Private Sub CommandButton1_Click()




Dim myCell As Range
Dim myTextBox As textbox


Set myCell = ActiveCell


'Set Textbox Size & Position


    With myCell
    Set myTextBox = .Parent.TextBoxes.Add(Top:=.Top, Left:=.Left, _
    Width:=130, Height:=50)
    End With
    
'Insert Contents of UserForm ComboBox


    With myTextBox
    .Caption = ComboBox1.Value & Chr(10) & ComboBox2.Value & Chr(10) & Now
    End With


End Sub

Thanks
Mark
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Mark

Try this, change the path for the image as required.
Code:
    With myTextBox
        .Caption = "THIS IS A TEST"
          .ShapeRange.Fill.UserPicture  "C:\Test\Logo.bmp"
    End With
 
Last edited:
Upvote 0
Try this:-
Straight from the "Macro Recorder" !!!!!!
Change Path to suit !!!
Code:
Private Sub CommandButton1_Click()
Dim myCell As Range
Dim myTextBox As TextBox
Set myCell = ActiveCell
With myCell
    Set myTextBox = .Parent.TextBoxes.Add(Top:=.Top, Left:=.Left, _
    Width:=130, Height:=50)
        With myTextBox.ShapeRange.Fill
            .Visible = msoTrue
            .UserPicture "C:\Users\USER1\Desktop\Bird Pictures\5.jpg"
            .TextureTile = msoFalse
        End With
    
    End With
    With myTextBox
    .Caption = "Testing" 'ComboBox1.Value & Chr(10) & ComboBox2.Value & Chr(10) & Now
    End With
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top