Results 1 to 4 of 4

Thread: VBA again...

  1. #1

    Thread Starter
    Fanatic Member coox's Avatar
    Join Date
    Oct 1999
    Posts
    550

    Post

    Anyone got any ideas on how to return a filename from the xldialogopen dialog? I can only seem to get it to return true.


  2. #2

    Thread Starter
    Fanatic Member coox's Avatar
    Join Date
    Oct 1999
    Posts
    550

    Post

    Am I posting these questions at the wrong forum? If so, can anyone tell me where I should be posting them (no rude ones)?

  3. #3
    Hyperactive Member billwagnon's Avatar
    Join Date
    Jul 1999
    Location
    St. Louis, Missouri, Mississippi Valley
    Posts
    290

    Post

    Use something like this:
    Dim FileToOpen as string

    FileToOpen = Application.GetOpenFilename("All Files,.*")

    Select Case FileToOpen
    Case False
    MsgBox "File not selected.", vbInformation
    'show your form again
    Case Is <> ""
    'show any form you need before the file opens
    Application.DisplayAlerts = False
    'this next part is recorded in VBA on Excel
    'to open a text file and format it automatically in Excel

    Workbooks.OpenText Filename:=FileToOpen,
    Origin:=xlWindows, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:= _
    Array(Array(0, 1) 'etc.

    I don't know of any place else to post VBA questions. Most people here are focused on straight VB, but VBA comes up occasionally. They are related enough that some response for VB can help you with VBA.

    The best thing about VBA is that you can record what you want to do, and then see the code.

    [This message has been edited by billwagnon (edited 11-03-1999).]

  4. #4

    Thread Starter
    Fanatic Member coox's Avatar
    Join Date
    Oct 1999
    Posts
    550

    Post

    Thanks billwagnon, works great. I don't suppose you have any suggestions for how to just select a folder, rather than an actual file. I'm looking to set the default location for output files....

Posting Permissions

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



Click Here to Expand Forum to Full Width