+ Reply to Thread
Results 1 to 6 of 6

Finding file

  1. #1
    DKS
    Guest

    Finding file

    Hi,

    Via a macro is there any means to have a DIALOG box popped up that would
    permit the user to browse the folders and select a file (or cancel the dialog
    box). Once the file is identified, I want the macro to be able to get the
    entire path including the file name BUT NOT OPEN the file. Thus the
    xlDialogOpen... is not useful for me.

    Any suggestions?

  2. #2
    mcg
    Guest

    Re: Finding file


    DKS napisal(a):
    > Hi,
    >
    > Via a macro is there any means to have a DIALOG box popped up that would
    > permit the user to browse the folders and select a file (or cancel the dialog
    > box). Once the file is identified, I want the macro to be able to get the
    > entire path including the file name BUT NOT OPEN the file. Thus the
    > xlDialogOpen... is not useful for me.
    >
    > Any suggestions?


    file = Application.GetOpenFilename
    mcg


  3. #3
    DKS
    Guest

    Re: Finding file

    Thanks this does the trick. Nevertheless on testing it, when clicking on
    cancel the resulting value is FALSE. Thus, how do I test for this in the
    macro? If I put

    IF NOT file

    then the above works well when I click cancel but not at all when I select a
    good file name; I get a 'type mismatch" error.

    Thanks for your previous tip.

    "mcg" wrote:

    >
    > DKS napisal(a):
    > > Hi,
    > >
    > > Via a macro is there any means to have a DIALOG box popped up that would
    > > permit the user to browse the folders and select a file (or cancel the dialog
    > > box). Once the file is identified, I want the macro to be able to get the
    > > entire path including the file name BUT NOT OPEN the file. Thus the
    > > xlDialogOpen... is not useful for me.
    > >
    > > Any suggestions?

    >
    > file = Application.GetOpenFilename
    > mcg
    >
    >


  4. #4
    Tom Ogilvy
    Guest

    Re: Finding file

    Dim file as String
    file = Application.GetOpenFilename
    if file = "False" then
    msgbox "You hit cancel"
    exit sub
    end if

    --
    Regards,
    Tom Ogilvy


    "DKS" wrote:

    > Thanks this does the trick. Nevertheless on testing it, when clicking on
    > cancel the resulting value is FALSE. Thus, how do I test for this in the
    > macro? If I put
    >
    > IF NOT file
    >
    > then the above works well when I click cancel but not at all when I select a
    > good file name; I get a 'type mismatch" error.
    >
    > Thanks for your previous tip.
    >
    > "mcg" wrote:
    >
    > >
    > > DKS napisal(a):
    > > > Hi,
    > > >
    > > > Via a macro is there any means to have a DIALOG box popped up that would
    > > > permit the user to browse the folders and select a file (or cancel the dialog
    > > > box). Once the file is identified, I want the macro to be able to get the
    > > > entire path including the file name BUT NOT OPEN the file. Thus the
    > > > xlDialogOpen... is not useful for me.
    > > >
    > > > Any suggestions?

    > >
    > > file = Application.GetOpenFilename
    > > mcg
    > >
    > >


  5. #5
    Jim Thomlinson
    Guest

    Re: Finding file

    Give this a try...

    Sub test()
    Dim strFile As String

    strFile = Application.GetOpenFilename

    If strFile = "False" Then
    MsgBox "No file selected"
    Exit Sub
    End If
    'The rest of your code...
    End Sub
    --
    HTH...

    Jim Thomlinson


    "DKS" wrote:

    > Thanks this does the trick. Nevertheless on testing it, when clicking on
    > cancel the resulting value is FALSE. Thus, how do I test for this in the
    > macro? If I put
    >
    > IF NOT file
    >
    > then the above works well when I click cancel but not at all when I select a
    > good file name; I get a 'type mismatch" error.
    >
    > Thanks for your previous tip.
    >
    > "mcg" wrote:
    >
    > >
    > > DKS napisal(a):
    > > > Hi,
    > > >
    > > > Via a macro is there any means to have a DIALOG box popped up that would
    > > > permit the user to browse the folders and select a file (or cancel the dialog
    > > > box). Once the file is identified, I want the macro to be able to get the
    > > > entire path including the file name BUT NOT OPEN the file. Thus the
    > > > xlDialogOpen... is not useful for me.
    > > >
    > > > Any suggestions?

    > >
    > > file = Application.GetOpenFilename
    > > mcg
    > >
    > >


  6. #6
    DKS
    Guest

    RE: Finding file

    Thanks to all for the help. It works.

    "DKS" wrote:

    > Hi,
    >
    > Via a macro is there any means to have a DIALOG box popped up that would
    > permit the user to browse the folders and select a file (or cancel the dialog
    > box). Once the file is identified, I want the macro to be able to get the
    > entire path including the file name BUT NOT OPEN the file. Thus the
    > xlDialogOpen... is not useful for me.
    >
    > Any suggestions?


+ 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