+ Reply to Thread
Results 1 to 8 of 8

form using windows explorer

  1. #1
    Spike
    Guest

    form using windows explorer

    Is there a way that i can create a form that acts like windows explorer or
    incorporates windows explorer so that a user can follow instructions on the
    form and select the relevant file from the windows explorer part of the form?

    I can get windows explorer to show by shell etc but need to show
    instructions at the same time.

    Any advices will be very gratefully received

    Many thanks
    --
    with kind regards

    Spike

  2. #2

    Re: form using windows explorer

    use the common dialog box control, or build a control of your own using
    list boxes, or (more simply) invoke the File Open command from VBA but
    just use this to get the file name - this example will get a text file,
    but can be adapted to pick up any file of the users choice

    FileToOpen = Application.GetOpenFilename("Text Files (*.txt), *.txt")


  3. #3
    Spike
    Guest

    Re: form using windows explorer

    Thank you. I am probably being very dim but i cannot find a control that
    will stick windows explorer on a form, i have checked tools/refs for other
    libraries etc.

    What i want to do is to have a form with instructions on the form and the
    form to also show windows explorer so if the user cannot see the file they
    need they can go to a different directory.
    --
    with kind regards

    Spike


    "[email protected]" wrote:

    > use the common dialog box control, or build a control of your own using
    > list boxes, or (more simply) invoke the File Open command from VBA but
    > just use this to get the file name - this example will get a text file,
    > but can be adapted to pick up any file of the users choice
    >
    > FileToOpen = Application.GetOpenFilename("Text Files (*.txt), *.txt")
    >
    >


  4. #4

    Re: form using windows explorer

    You need to right click on the toolbox to get more controls, then you
    should find the microsoft common dialog control - from help:-

    CommonDialog Control


    The CommonDialog control provides a standard set of dialog boxes for
    operations such as opening and saving files, setting print options, and
    selecting colors and fonts. The control also has the ability to display
    help by running the Windows Help engine.

    Syntax

    CommonDialog

    Remarks

    The CommonDialog control provides an interface between Visual Basic and
    the routines in the Microsoft Windows dynamic-link library Commdlg.dll.
    To create a dialog box using this control, Commdlg.dll must be in your
    Microsoft Windows SYSTEM directory.

    You use the CommonDialog control in your application by adding it to a
    form and setting its properties. The dialog displayed by the control is
    determined by the methods of the control. Atrun time, a dialog box is
    displayed or the help engine is executed, when the appropriate method
    is invoked; atdesign time, the CommonDialog control is displayed as an
    icon on a form. This icon can't be sized.

    The CommonDialog control can display the following dialogs using the
    specified method.

    Method Dialog Displayed
    ShowOpen Show Open Dialog Box
    ShowSave Show Save As Dialog Box
    ShowColor Show Color Dialog Box
    ShowFont Show Font Dialog Box
    ShowPrinter Show Print or Print Options Dialog Box
    ShowHelp Invokes the Windows Help Engine


    The CommonDialog control automatically provides context sensitive help
    on the interface of the dialog boxes by clicking:

    The What's This help button in the title bar then clicking the item for
    which you want more information.


    The right mouse button over the item for which you want more
    information then selecting the What's This command in the displayed
    context menu.
    The operating system provides the text shown in the Windows 95 Help
    popup. You can also display a Help button on the dialog boxes with the
    CommonDialog control by setting the Flags property, however, you must
    provide the help topics in this situation.

    Note There is no way to specify where a dialog box is displayed.

    For More Information To see help topics for each dialog, click on See
    Also.


    However, I'd still use the Application.GetOpenFilename("Text Files
    (*.txt), *.txt") method myself

    for example, with a text box visible and a command button you can set
    the text box to the file they want by using

    TextBox1.Text = Application.GetOpenFilename("Text Files (*.txt),
    *.txt")


    as I say, change the mask from *.txt to whatever mask you want!


  5. #5

    Re: form using windows explorer

    You need to right click on the toolbox to get more controls, then you
    should find the microsoft common dialog control - from help:-

    CommonDialog Control


    The CommonDialog control provides a standard set of dialog boxes for
    operations such as opening and saving files, setting print options, and
    selecting colors and fonts. The control also has the ability to display
    help by running the Windows Help engine.

    Syntax

    CommonDialog

    Remarks

    The CommonDialog control provides an interface between Visual Basic and
    the routines in the Microsoft Windows dynamic-link library Commdlg.dll.
    To create a dialog box using this control, Commdlg.dll must be in your
    Microsoft Windows SYSTEM directory.

    You use the CommonDialog control in your application by adding it to a
    form and setting its properties. The dialog displayed by the control is
    determined by the methods of the control. Atrun time, a dialog box is
    displayed or the help engine is executed, when the appropriate method
    is invoked; atdesign time, the CommonDialog control is displayed as an
    icon on a form. This icon can't be sized.

    The CommonDialog control can display the following dialogs using the
    specified method.

    Method Dialog Displayed
    ShowOpen Show Open Dialog Box
    ShowSave Show Save As Dialog Box
    ShowColor Show Color Dialog Box
    ShowFont Show Font Dialog Box
    ShowPrinter Show Print or Print Options Dialog Box
    ShowHelp Invokes the Windows Help Engine


    The CommonDialog control automatically provides context sensitive help
    on the interface of the dialog boxes by clicking:

    The What's This help button in the title bar then clicking the item for
    which you want more information.


    The right mouse button over the item for which you want more
    information then selecting the What's This command in the displayed
    context menu.
    The operating system provides the text shown in the Windows 95 Help
    popup. You can also display a Help button on the dialog boxes with the
    CommonDialog control by setting the Flags property, however, you must
    provide the help topics in this situation.

    Note There is no way to specify where a dialog box is displayed.

    For More Information To see help topics for each dialog, click on See
    Also.


    However, I'd still use the Application.GetOpenFilename("Text Files
    (*.txt), *.txt") method myself

    for example, with a text box visible and a command button you can set
    the text box to the file they want by using

    TextBox1.Text = Application.GetOpenFilename("Text Files (*.txt),
    *.txt")


    as I say, change the mask from *.txt to whatever mask you want!


  6. #6

    Re: form using windows explorer

    You need to right click on the toolbox to get more controls, then you
    should find the microsoft common dialog control - from help:-

    CommonDialog Control


    The CommonDialog control provides a standard set of dialog boxes for
    operations such as opening and saving files, setting print options, and
    selecting colors and fonts. The control also has the ability to display
    help by running the Windows Help engine.

    Syntax

    CommonDialog

    Remarks

    The CommonDialog control provides an interface between Visual Basic and
    the routines in the Microsoft Windows dynamic-link library Commdlg.dll.
    To create a dialog box using this control, Commdlg.dll must be in your
    Microsoft Windows SYSTEM directory.

    You use the CommonDialog control in your application by adding it to a
    form and setting its properties. The dialog displayed by the control is
    determined by the methods of the control. Atrun time, a dialog box is
    displayed or the help engine is executed, when the appropriate method
    is invoked; atdesign time, the CommonDialog control is displayed as an
    icon on a form. This icon can't be sized.

    The CommonDialog control can display the following dialogs using the
    specified method.

    Method Dialog Displayed
    ShowOpen Show Open Dialog Box
    ShowSave Show Save As Dialog Box
    ShowColor Show Color Dialog Box
    ShowFont Show Font Dialog Box
    ShowPrinter Show Print or Print Options Dialog Box
    ShowHelp Invokes the Windows Help Engine


    The CommonDialog control automatically provides context sensitive help
    on the interface of the dialog boxes by clicking:

    The What's This help button in the title bar then clicking the item for
    which you want more information.


    The right mouse button over the item for which you want more
    information then selecting the What's This command in the displayed
    context menu.
    The operating system provides the text shown in the Windows 95 Help
    popup. You can also display a Help button on the dialog boxes with the
    CommonDialog control by setting the Flags property, however, you must
    provide the help topics in this situation.

    Note There is no way to specify where a dialog box is displayed.

    For More Information To see help topics for each dialog, click on See
    Also.


    However, I'd still use the Application.GetOpenFilename("Text Files
    (*.txt), *.txt") method myself

    for example, with a text box visible and a command button you can set
    the text box to the file they want by using

    TextBox1.Text = Application.GetOpenFilename("Text Files (*.txt),
    *.txt")


    as I say, change the mask from *.txt to whatever mask you want!


  7. #7
    Registered User
    Join Date
    01-20-2006
    Posts
    19
    From Help:

    Create a button on your form called cmdSelect_File

    Add the following code to Private Sub cmdSelect_File_Click():


    'Declare a variable as a FileDialog object.
    Dim fd As FileDialog

    'Create a FileDialog object as a File Picker dialog box.
    Set fd = Application.FileDialog(msoFileDialogFilePicker)

    'Declare a variable to contain the path
    'of each selected item. Even though the path is a String,
    'the variable must be a Variant because For Each...Next
    'routines only work with Variants and Objects.
    Dim vrtSelectedItem As Variant

    'Use a With...End With block to reference the FileDialog object.
    With fd

    'Use the Show method to display the File Picker dialog box and return the user's action.
    'The user pressed the action button.
    If .Show = -1 Then

    'Step through each string in the FileDialogSelectedItems collection.
    For Each vrtSelectedItem In .SelectedItems

    'vrtSelectedItem is a String that contains the path of each selected item.
    'You can use any file I/O functions that you want to work with this path.
    'This example simply displays the path in a message box.
    MsgBox "The path is: " & vrtSelectedItem

    Next vrtSelectedItem
    'The user pressed Cancel.
    Else
    End If
    End With

    'Set the object variable to Nothing.
    Set fd = Nothing

  8. #8
    Spike
    Guest

    Re: form using windows explorer

    Thank you both very much extremely helpful, i did not appreciate that the
    microsoft common dialogue control was the one i wanted. Anyway as there
    appears to me some issue it does not work but have used the GetOpenFileName
    which is grand.

    Thank you
    --
    with kind regards

    Spike


    "H.A. de Wilde" wrote:

    >
    > From Help:
    >
    > Create a button on your form called cmdSelect_File
    >
    > Add the following code to Private Sub cmdSelect_File_Click():
    >
    >
    > 'Declare a variable as a FileDialog object.
    > Dim fd As FileDialog
    >
    > 'Create a FileDialog object as a File Picker dialog box.
    > Set fd = Application.FileDialog(msoFileDialogFilePicker)
    >
    > 'Declare a variable to contain the path
    > 'of each selected item. Even though the path is a String,
    > 'the variable must be a Variant because For Each...Next
    > 'routines only work with Variants and Objects.
    > Dim vrtSelectedItem As Variant
    >
    > 'Use a With...End With block to reference the FileDialog object.
    > With fd
    >
    > 'Use the Show method to display the File Picker dialog box and
    > return the user's action.
    > 'The user pressed the action button.
    > If .Show = -1 Then
    >
    > 'Step through each string in the FileDialogSelectedItems
    > collection.
    > For Each vrtSelectedItem In .SelectedItems
    >
    > 'vrtSelectedItem is a String that contains the path of
    > each selected item.
    > 'You can use any file I/O functions that you want to
    > work with this path.
    > 'This example simply displays the path in a message
    > box.
    > MsgBox "The path is: " & vrtSelectedItem
    >
    > Next vrtSelectedItem
    > 'The user pressed Cancel.
    > Else
    > End If
    > End With
    >
    > 'Set the object variable to Nothing.
    > Set fd = Nothing
    >
    >
    > --
    > H.A. de Wilde
    > ------------------------------------------------------------------------
    > H.A. de Wilde's Profile: http://www.excelforum.com/member.php...o&userid=30679
    > View this thread: http://www.excelforum.com/showthread...hreadid=538789
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1