I'm writing a code for excel, that will have a form witch include a textbox and button. Button selects a folder directory and writes it in textbox. Part of the form is this!
The code for it is this
Private Sub CommandButton1_Click()
Dim diaFolder As FileDialog
On Error GoTo ErrorHandler
Set diaFolder = Application.FileDialog(msoFileDialogFolderPicker)
diaFolder.AllowMultiSelect = False
diaFolder.Title = "Select a folder then hit OK"
diaFolder.Show
TextBox1.Text = diaFolder.SelectedItems(1)
Set diaFolder = Nothing
Exit Sub
ErrorHandler:
Msg = "No folder selected, you must select a folder for program to run"
Style = vbError
Title = "Need to Select Folder"
Response = MsgBox(Msg, Style, Title)
End Sub
The problem is how to save the "textbox" value to show it every time I call the userform; it should't depend on a cell in workbook as it will be an add-in and will be called from the ribbon button.
Any ideas will be appreciated very much ! Thanks.