abi_learn_vba
Board Regular
- Joined
- Nov 6, 2009
- Messages
- 215
Hi,
I have used a Userform to browse a file, and the file path in the textbox is saved to the variable "input", please see the code below. Then i called and procedure "ProcessInput" (Which is in Module) to open the file. But when the module is opened the Input value shows "empty" and it does not have the path name. But as i see the filename is saved in the variable "input" in "Private Sub cmdOK_Click() ". Can any one say if i am wrong in doing this?
I have used a Userform to browse a file, and the file path in the textbox is saved to the variable "input", please see the code below. Then i called and procedure "ProcessInput" (Which is in Module) to open the file. But when the module is opened the Input value shows "empty" and it does not have the path name. But as i see the filename is saved in the variable "input" in "Private Sub cmdOK_Click() ". Can any one say if i am wrong in doing this?
Code:
Private Sub cmdOK_Click()
If Trim(TextBox1.Text) = "" then
MsgBox "One or All Files are not Selected!! Try Again"
Exit Sub
End If
Input = TextBox1.Text
Call ProcesInput
Unload Me
End Sub
Public Sub ProcesInput()
Set myfile = Workbooks.Open(Input)
End Sub