How to Reset ButtonName and Filters in msoFileDialogOpen?

Discussion in 'Word VBA Beginners' started by Junya Nitta, Oct 10, 2010.

  1. Junya Nitta

    Junya Nitta Guest

    I am using msoFileDialogOpen or msoFileDialogFilePicker to select
    specific files.

    After I use the procedure "FilePath_FolderPath_1" below, the other
    procedure "FilePath_FolderPath_2" gives you the same filters and
    button name that have been set in the procedure
    "FilePath_FolderPath_1", although "FilePath_FolderPath_2" does not
    have .ButtonName or .Filters.Add method.

    I want the default button name and filters in the procedure
    "FilePath_FolderPath_2".

    Could you tell me how to reset the button name and filters into the
    original condition showing the default setting.

    Thanks in advance.


    Sub FilePath_FolderPath_1()

    Dim fd As FileDialog
    Dim myFileName As String
    Dim myFolderPath As String
    Dim myFilePath As String

    On Error GoTo EH

    Set fd = Application.FileDialog(msoFileDialogOpen)

    With fd
    .Title = "Select Word Document"
    .AllowMultiSelect = False
    .ButtonName = "Word_Files_Open"
    .Filters.Clear
    .Filters.Add "All files", "*.*", 1
    .Filters.Add "All Word Documents", "*.doc; *.docx", 2
    .FilterIndex = 2
    If .Show = -1 Then
    myFilePath = .SelectedItems(1)
    myFileName = Right(myFilePath, Len(myFilePath) -
    InStrRev(myFilePath, "\"))
    myFolderPath = Left(myFilePath, Len(myFilePath) -
    Len(myFileName) - 1)

    MsgBox "Folder Path:" & myFolderPath & vbCr & _
    "File Path:" & myFilePath & vbCr & _
    "File Name:" & myFileName
    End If
    End With

    Set fd = Nothing

    On Error GoTo 0
    Exit Sub

    EH:

    MsgBox Err.Description

    End Sub

    ----------------------------------------------------------------------
    Sub FilePath_FolderPath_2()

    Dim fd As FileDialog
    Dim myFileName As String
    Dim myFolderPath As String
    Dim myFilePath As String

    On Error GoTo EH

    Set fd = Application.FileDialog(msoFileDialogOpen)

    With fd
    .Title = "Select Word Document"
    .AllowMultiSelect = False
    If .Show = -1 Then
    myFilePath = .SelectedItems(1)
    myFileName = Right(myFilePath, Len(myFilePath) -
    InStrRev(myFilePath, "\"))
    myFolderPath = Left(myFilePath, Len(myFilePath) -
    Len(myFileName) - 1)

    MsgBox "Folder Path:" & myFolderPath & vbCr & _
    "File Path:" & myFilePath & vbCr & _
    "File Name:" & myFileName
    End If
    End With

    Set fd = Nothing

    On Error GoTo 0
    Exit Sub

    EH:

    MsgBox Err.Description

    End Sub
     
    Junya Nitta, Oct 10, 2010
    #1
    1. Advertisements

  2. Junya Nitta

    Junya Nitta Guest

    I am replying to the above question of myself.

    After I posted the above question, I found out that ButtonName and
    Filters in msoFileDialogOpen are reset to the default condition if
    Word is restarted.

    Thank you for your support.

    Junya Nitta
     
    Junya Nitta, Oct 15, 2010
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Solomon Antony

    Reset numbering for text where style is applied

    Solomon Antony, Aug 28, 2003, in forum: Word VBA Beginners
    Replies:
    1
    Views:
    130
    Cindy Meister -WordMVP-
    Sep 1, 2003
  2. Rebecca

    Search and Replace and/or Macro

    Rebecca, Aug 31, 2003, in forum: Word VBA Beginners
    Replies:
    5
    Views:
    147
    Doug Robbins - Word MVP
    Aug 31, 2003
  3. Mark Eidemiller

    Variables and Merges and stuff

    Mark Eidemiller, Dec 1, 2003, in forum: Word VBA Beginners
    Replies:
    2
    Views:
    117
    Mark Eidemiller
    Dec 3, 2003
  4. Tisha
    Replies:
    3
    Views:
    138
    Jean-Guy Marcil
    Feb 20, 2004
  5. JMCN
    Replies:
    0
    Views:
    68
  6. Chris Moorhead
    Replies:
    7
    Views:
    280
    Chris Moorhead
    Nov 30, 2005
  7. Excel 009

    Loop txt files and make change and save

    Excel 009, Oct 18, 2006, in forum: Word VBA Beginners
    Replies:
    9
    Views:
    149
    Tony Jollans
    Oct 19, 2006
  8. CatMarieS

    selecting field codes and copying and pasting them

    CatMarieS, Jun 15, 2007, in forum: Word VBA Beginners
    Replies:
    1
    Views:
    133
    Helmut Weber
    Jun 15, 2007
Loading...