+ Reply to Thread
Results 1 to 6 of 6

a button to open up "My Computer" on an excel sheet

  1. #1
    DorisM
    Guest

    a button to open up "My Computer" on an excel sheet

    I'm trying to create a command button using VBA in an excel sheet that opens
    up "My Computer". So it will allow the user to go to whatever folder that
    they have their file saved at. Similar to the "Open" command in most window
    applications.

    I'm at level I in VBA, so I'm not sure if this is possible.

    Thank you.

    Doris

  2. #2
    Jake Marx
    Guest

    Re: a button to open up "My Computer" on an excel sheet

    Hi Doris,

    DorisM wrote:
    > I'm trying to create a command button using VBA in an excel sheet
    > that opens up "My Computer". So it will allow the user to go to
    > whatever folder that they have their file saved at. Similar to the
    > "Open" command in most window applications.
    >
    > I'm at level I in VBA, so I'm not sure if this is possible.


    The GetOpenFilename method will allow the user to select a file. Here's
    some sample code that shows how to use it:

    Sub DemoFileSelect()
    Dim vResponse As Variant

    vResponse = Application.GetOpenFilename( _
    FileFilter:="Microsoft Excel Files (*.xls), *.xls", _
    Title:="Please select your file")

    If vResponse <> False Then
    MsgBox Prompt:="You selected '" & vResponse & "'.", _
    Buttons:=vbOKOnly Or vbInformation
    Else
    MsgBox Prompt:="You cancelled.", _
    Buttons:=vbOKOnly Or vbInformation
    End If
    End Sub

    If you drop a CommandButton from the Control Toolbox onto your worksheet,
    you can double-click it and call the demo from there:

    Private Sub CommandButton1_Click()
    DemoFileSelect
    End Sub

    --
    Regards,

    Jake Marx
    MS MVP - Excel
    www.longhead.com

    [please keep replies in the newsgroup - email address unmonitored]


  3. #3
    Dick Kusleika
    Guest

    Re: a button to open up "My Computer" on an excel sheet

    Doris

    Maybe the GetOpenFileName method will work for you.

    http://www.*****-blog.com/archives/2...topenfilename/


    --
    **** Kusleika
    Excel MVP
    Daily Dose of Excel
    www.*****-blog.com

    DorisM wrote:
    > I'm trying to create a command button using VBA in an excel sheet
    > that opens up "My Computer". So it will allow the user to go to
    > whatever folder that they have their file saved at. Similar to the
    > "Open" command in most window applications.
    >
    > I'm at level I in VBA, so I'm not sure if this is possible.
    >
    > Thank you.
    >
    > Doris




  4. #4
    sebastienm
    Guest

    RE: a button to open up "My Computer" on an excel sheet

    Hi,

    The GetOpenFileName function display the regular Open dialog and the user
    can browse and choose a file. Once the user clicks Ok or Cancel, the
    GetOpenFileName function returns a string containing the path+name of the
    selected file (or False if the user clicked Cancel). Impoirtant: The function
    doesn't open the file, it just retuns its path+name, so you need some
    additional code to process the file (open it, print it, or whatever you need
    to do). (see online help for more info)

    1- in a module, add the code to let a user choose a file:
    Sub UserChooseFile()
    Dim f As Variant
    f = Application.GetOpenFilename("Excel File (*.xl),*.xls", , "Open
    dialog test")
    If f <> False Then
    MsgBox "Open " & f
    Else
    MsgBox "the Open was cancelled"
    End If
    '***** add process code here ******
    End Sub
    2-on a sheet, add a button from the Forms toolbar (not the Control Toolbox
    toolbar; menu View > Toolbars > Forms)
    If the Macro dialog doesn't popup right away, just right click the button
    and choose Assign Macro. There choose the UserChooseFile macro.

    I hope this helps,
    --
    Regards,
    Sébastien
    <http://www.ondemandanalysis.com>


    "DorisM" wrote:

    > I'm trying to create a command button using VBA in an excel sheet that opens
    > up "My Computer". So it will allow the user to go to whatever folder that
    > they have their file saved at. Similar to the "Open" command in most window
    > applications.
    >
    > I'm at level I in VBA, so I'm not sure if this is possible.
    >
    > Thank you.
    >
    > Doris


  5. #5
    Tom Ogilvy
    Guest

    Re: a button to open up "My Computer" on an excel sheet

    fname = Application.GetOpenFileName()

    shows the file open dialog and allows traversing directories to find or
    establish the location of the file.

    for saving

    fName = Application.GetSaveAsFileName()

    Note that neither of these open or save the file selected - they return the
    fully qualified name as a string

    --
    Regards,
    Tom Ogilvy


    "DorisM" <[email protected]> wrote in message
    news:[email protected]...
    > I'm trying to create a command button using VBA in an excel sheet that

    opens
    > up "My Computer". So it will allow the user to go to whatever folder that
    > they have their file saved at. Similar to the "Open" command in most

    window
    > applications.
    >
    > I'm at level I in VBA, so I'm not sure if this is possible.
    >
    > Thank you.
    >
    > Doris




  6. #6
    DorisM
    Guest

    RE: a button to open up "My Computer" on an excel sheet

    Thank you guys. It works.

    Doris

    "DorisM" wrote:

    > I'm trying to create a command button using VBA in an excel sheet that opens
    > up "My Computer". So it will allow the user to go to whatever folder that
    > they have their file saved at. Similar to the "Open" command in most window
    > applications.
    >
    > I'm at level I in VBA, so I'm not sure if this is possible.
    >
    > Thank you.
    >
    > Doris


+ 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