I have textbox and command button in the form1.
I will input path in the textbox
After the clicking the command button, workbook from the path location should open and need to the require macros code like copying , etc
when i tried using the . I getting error saying that file1.xlsx not found . plz help
Private Sub CommandButton1_Click()
Set wb1 = Workbooks.Open("file1")
End Sub
Private Sub TextBox1_Change()
Dim file1 As String
file1 = TextBox1.Value
End Sub
Private Sub UserForm_Click()
End Sub
The suggestions in the comments above will get you where you need to go, but if I may suggest… rather than using a textbox for the user to enter the name in, use the GetOpenFilename dialog. In this way you can ensure that the path is valid and the file actually exists. It also gives the user a nice GUI which is more like what they’re used to for a File -> Open dialog. Something like this: