Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Dec 2001
    Location
    Br. Columbia, Canada
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Display Open Files Dialog Box (Word 97)

    I am new to Word macros but have some experience with VBA as it applies to Excel. Word objects are a bit of a mystery to me.
    Can anyone tell me the code to display the Open Files Dialog Box so that the user can select a text file and open it as a word document? (The file names will vary and are alpha numeric so do not lend themselves to an inputbox solution.)

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Display Open Files Dialog Box (Word 97)

    This seems to do the trick, I'm not sure why I needed both .Display and .Execute, but it wouldn't accept the file name as a valid parameter without the .Display.

    Public Sub OpenTextFile()
    With Dialogs(wdDialogFileOpen)
    .Name = "*.txt"
    If .Display = -1 Then
    .Execute
    End If
    End With
    End Sub

    StuartR

  3. #3
    Lounger
    Join Date
    Dec 2001
    Location
    Br. Columbia, Canada
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Display Open Files Dialog Box (Word 97)

    Thanks Stuart, I really appreciate your help.

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Display Open Files Dialog Box (Word 97)

    It makes sense if you think about it this way:

    .Show = .Display + .Execute

    The latter method is most useful when you want to change something after the user click OK.

Posting Permissions

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