I have created a custom menu that displays a dialog box when clicked on. I have made the "Browse" button to call a FileOpenDlg() statement. I want the file that the user selects to populate in the EditText space. I would then like to have my app read that string and store it, so that it can be used in a sub procedure when the user clicks run. Any suggestions?

For Example: I want it to behave like a box that asks you to pick a file to upload. The browse button is used to browse for the file, and I want the "run" button to behave like an "upload" button. I was unable to post the picture on here of my dialog box, but that is the concept i am going for. Here is the code for the dialog box and the handler:

    Sub Leads
Title "Leads"
    Width 198 Height 80
Control StaticText
    Title "Select Leads File"
    Position 4, 16
Control EditText
    ID "2"
Control Button
    Title "Browse"
    Calling PickLeadsFile
    ID "22"
    Position 152, 15
Control StaticText
    Title "Run Leads Update?"
    Position 4, 52
Control OkButton
    Title "Run"
    ID "222"
    Position 74, 48
Control CancelButton
    Position 118, 48

    End Sub  

    Sub PickLeadsFile
    Dim Leads_filename As String
Leads_filename = FileOpenDlg("C:\Users\dykesb01\Desktop\Test","","XLS","Open Leads File")
    Alter Control 2
    Title From Variable Leads_filename
    End Sub

Your dialog has at least three controls:

  • A Edit text control with an ID
  • A Button with the title "Browse"
  • A OKButton with the title "Upload"

When you click the Browse button you should call a handler (a sub procedure) where you use the FileOpenDlg() function to ask the user to pick a file of a certain type.

Then you should add the selected file name to the edit text control using the Alter Control statement.

When the user hits the Upload button you can use ReadControlValue() to read the selected file name, open the file using Open File .. For Input and read values from the file using the Input # statement.

Is that what you are looking for?

| improve this answer | |
  • That is exactly what I needed. Can't thank you enough for your help! – user15642 May 23 '13 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.