Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Nottingham, UK, Nottinghamshire, England
    Posts
    190
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Excel97 open text file

    I'd like to be able to programatically open a text file and parse it into columns. There is the TextOpen construct that allows me to do this, mimicing the Text File Input Wizard. So far so good. However, I really want to be able to ask the user for the text file to input. If I use the Dialogs(xlDialogOpen) code, I can only 'Show', thereby actually opening the file and provoking the wizard (which I want to avoid and use my own programmed parse criteria). I can't use a 'Display' (as I could if this was a Word dialog), which would enable me to retrieve the file name and use it in my TextOpen statement.

    Does anyone have any idea how I can solicit a user in Excel to obtain a file name WITHOUT actually opening the file?

    TIA again.

  2. #2
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Cornwall, England
    Posts
    393
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excel97 open text file

    I would go along the lines of using the Common Dialog Control. if this is not already in your toolbox then right click and select additional controls. Scroll down to Microsoft Common Dialog Control and tick it. Drop this new control onto a form and give it a name eg.'dlgFindText'.
    Add a command button and in the click event use the line dlgFindText.ShowOpen to show the dialog box in its Open style (there is also the ability to ShowFont, ShowSave, ShowPrinter...). Once a file has been selected by the user the UNC is returned to dlgFindtext.FileName and can be used by you to manipulate the file.
    Hope this helps

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Cornwall, England
    Posts
    393
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excel97 open text file

    as soon as i posted the above i remembered that excel (not sure about word too ?)has the GetOpenFileName method (also GetSaveasFileName). This will give you the same functions without the mess of getting hold of the other control.
    For full details and example look it up in the online help, this method has a good example to follow.
    sorry for the confusion!

  4. #4
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Nottingham, UK, Nottinghamshire, England
    Posts
    190
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excel97 open text file

    Hi Fatherjack!

    Brilliant! Just what I was after! I have not seen any mention of these commands in any Excel programming books or articles I have, so I wonder how you're meant to know about them? Never mind, thanks again!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •