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

    Word97 Dialogs File Open

    In Word97 under Win98SE, I've coded a macro which uses
    With Dialogs(wdDialogFileOpen)
    .Name = "*.doc"
    .Display
    strFileName = .Name
    End With

    Now, by the example given in Woody's "Word 97 Annoyances" book, I should be able to find the FULL file name (including path) in strFileName, but I don't - it's only the actual file name. I really want the path name, i.e. the directory itself, so that I can properly open this and other files within it. How can I get this information from the dialog box? Any ideas?

    TIA

  2. #2
    Star Lounger
    Join Date
    Dec 2000
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word97 Dialogs File Open

    If you want the directory itself, you could just add a line of code just below the .Display line:

    strDirName = CurDir()

    However, for whatever reason, you don't need the directory name here to open up the user's selected file. After your chunk of code, if you add the following:

    'if user doesn't dismiss dialog
    If .Display <> -1 Then
    Documents.Open strFileName
    End If

    This will open up the file chosen by the user. No path is needed in this case. Go figure.

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word97 Dialogs File Open

    <pre>Try trFileName = .FullName
    ====
    </pre>


  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: Word97 Dialogs File Open

    Thanks for that - CurDir() is just what I need! Actually, I also continued reading Woody's book, and came across some WordBasic that does the trick too, namely
    WordBasic.[FileNameInfo$](strFileName, 5)
    The filename on its own is the same replacing 5 with 3, and without the extension is 4 replacing 5. This gives the same results! Having assigned the .Name from the dialog to strFileName, the variable shows everywhere with a value of the filename&extension only, yet the WordBasic routine can extract the path from that variable without difficulty! Got me puzzled anyway.

    Thanks again

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

    Re: Word97 Dialogs File Open

    Thanks for that, but .FullName is not a supported property of the dialog. I've found some WordBasic to do the job (see other response), and someone suggested CurDir() which also works.

    Thanks for taking the time to reply though.

Posting Permissions

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