Error when running macro

Anmol_happy

New Member
Joined
Aug 17, 2022
Messages
7
Office Version
  1. 2016
Platform
  1. Windows
Can anyone help me to solve this syntax of of adding file path to TEXTBOX

1660791192492.png


This is my UI form


1660791327665.png
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Make sure to use the right name for the textbox object. Find the name by inspecting the property box. I suspect it is "TextBox4" , not "textbox 4". If so then,

VBA Code:
        Private Sub CommandButton1_Click()
            Dim a As String
        
            a = Application.GetOpenFilename
            Me.TextBox4.Value = a
        End Sub
 
Upvote 0
As that looks to be a Form Control textbox, try
VBA Code:
Sheet1.Shapes("TextBox 4").TextFrame.Characters.Caption = a
 
Upvote 0
Solution
Make sure to use the right name for the textbox object. Find the name by inspecting the property box. I suspect it is "TextBox4" , not "textbox 4". If so then,

VBA Code:
        Private Sub CommandButton1_Click()
            Dim a As String
       
            a = Application.GetOpenFilename
            Me.TextBox4.Value = a
        End Sub


Thanks but I am getting this error:

1660835966185.png
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,901
Members
449,097
Latest member
dbomb1414

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