open folder from access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Trevor2007
    New Member
    • Feb 2008
    • 68

    open folder from access

    I would like to open a folder from command button and I am not having any luck;
    Code:
    ...
      Dim stdfile as string
      open stdfile "c:\temp"
    End sub
    and I am getting error because I have nothing after open, as far as I know my code can be all wrong.
    Thanks for helping Trevor2007
  • Scott Price
    Recognized Expert Top Contributor
    • Jul 2007
    • 1384

    #2
    What do you mean: Open?

    Are you wanting an Open File dialog box, a Windows Explorer window with the Folder displayed?

    Regards,
    Scott

    Comment

    • Trevor2007
      New Member
      • Feb 2008
      • 68

      #3
      Originally posted by Scott Price
      What do you mean: Open?

      Are you wanting an Open File dialog box, a Windows Explorer window with the Folder displayed?

      Regards,
      Scott
      I want to open the folder as if someone when to the folder in a dir and opend it, so if someone clicked the command button it would automaticly open the folder, (not windows exlorer view), if this explination doesn't help let me know. thanx

      Comment

      • Scott Price
        Recognized Expert Top Contributor
        • Jul 2007
        • 1384

        #4
        That doesn't really help all that much, sorry :-( There are really only two ways to 'open' a folder. The two I mentioned above...

        If you want the person to be able to browse through and open a file contained in that folder then you need the Open File Dialog box.

        Otherwise, if you just want them to view the contents of the folder, (which includes unrestricted ability to interact with files, including opening, etc...) then you need to call the Windows Explorer.

        Here are instructions for how to implement the File Dialog box control, includes full code that you should need for opening whatever type of file that your users wish.

        Regards,
        Scott

        Comment

        • Trevor2007
          New Member
          • Feb 2008
          • 68

          #5
          Originally posted by Scott Price
          That doesn't really help all that much, sorry :-( There are really only two ways to 'open' a folder. The two I mentioned above...

          If you want the person to be able to browse through and open a file contained in that folder then you need the Open File Dialog box.

          Otherwise, if you just want them to view the contents of the folder, (which includes unrestricted ability to interact with files, including opening, etc...) then you need to call the Windows Explorer.

          Here are instructions for how to implement the File Dialog box control, includes full code that you should need for opening whatever type of file that your users wish.

          Regards,
          Scott
          ok, thanks, I have decided to go with the windows explorer to open the folder (since its o a network drive, i figure what hey , they can see there files , as aposed to letting the browse for the dir)
          I now have a follow up question, This db reads emails and downloads the attachments to a folder, while commenting at the end of the email what the file(s) are (this is in a private sub), when opening the folder, how can I have only the file(s) download for that email displayed?
          the line in the private sub to comment attachment(s) downloaded and location is :
          [code=VBA]
          Me.Body = Me.Body & vbCrLf & locmsg & savefile & FileName & SeqNum & "." & Extension & vbNewLine
          [/Code]
          Me.[Body] is is textbox that contains the body of the email,
          locmsg is just text to precede file location
          fileName is the the name of the file
          seqNum is the sequential # that is concatinated to the file name
          This code is on the form that pulls the email from outlook
          the form the end user uses to view this information does not contain this code because they are just pulling it from the DB table.
          and help?
          Thanx
          ps. Im guessing the line to find there files would be somthing like :
          [CODE=VBA]
          Len ( FileName&SeqNum ) = 1 Then
          .show
          [/Code]
          if you are wondering why the drive change it's simply because the process is the same but end result is for a multi user DB

          Comment

          • Scott Price
            Recognized Expert Top Contributor
            • Jul 2007
            • 1384

            #6
            In the link I gave you, you will find all the instructions you need in order to set up the folder browse dialog box, I strongly suggest using it instead of attempting to run the Windows Explorer, since there is no way to limit the Windows Explorer to the files/paths you are wanting.

            In order to limit the opening ability of the users to only those files that are included in their email attachment you will need to slightly modify the code that is provided in the link.

            I will give you an example and you can let me know if you need more help after trying this:
            [CODE=vb]
            Private Sub Command2_Click( )

            Const conVerticalOnly As Integer = 2
            'Dim fsoSysObj As FileSystemObjec t
            Dim fd As FileDialog, strFilesSelecte d As String, blnRetVal As Boolean

            Set fd = Application.Fil eDialog(msoFile DialogFilePicke r)

            'Declare a variable to contain the path, it must be a Variant becase
            'the For ... Each construct requires it
            Dim vrtSelectedItem As Variant

            Restart:

            With fd
            .AllowMultiSele ct = False
            .Title = "Browse Files"
            If .Show = -1 Then
            For Each vrtSelectedItem In .SelectedItems
            If Left(vrtSelecte dItem, 15) <> "D:\Access Code\" Then
            MsgBox "Please select a valid path."
            GoTo Restart:
            End If
            'Now, will only be one since MultiSelect = False
            strFilesSelecte d = vrtSelectedItem
            blnRetVal = Execute_Program (strFilesSelect ed, "", "")
            Next vrtSelectedItem
            Else
            'The user pressed Cancel
            End If
            End With

            Set fd = Nothing

            Me!Text0.Scroll Bars = conVerticalOnly
            Me!Text0 = strFilesSelecte d

            End Sub[/CODE]

            This example restricts the users from opening any file that isn't located in a specific path, in this case: D:\Access Code\.

            You will need to set a string variable that holds the FileName & SeqNum & "." & Extension information, then test your vrtSelectedItem to make sure it corresponds to the allowed file.

            Regards,
            Scott

            Comment

            • Scott Price
              Recognized Expert Top Contributor
              • Jul 2007
              • 1384

              #7
              As an aside, thanks for attempting to use the code tags! Instructions on their use:

              Select your code text, then simply click on the # icon on the top of this reply window. To reflect the language, you can manually edit the first tag to look like this: [CODE=vb] for vba, change =sql for SQL, etc. Thanks!

              Regards,
              Scott

              Comment

              • eliza81
                New Member
                • Jun 2010
                • 1

                #8
                Originally posted by Trevor2007
                I would like to open a folder from command button and I am not having any luck;
                Code:
                ...
                  Dim stdfile as string
                  open stdfile "c:\temp"
                End sub
                and I am getting error because I have nothing after open, as far as I know my code can be all wrong.
                Thanks for helping Trevor2007
                Following is the code sample used to display the outlook folder dialog using VB.NET
                Code:
                Dim objOutlook As Object
                Dim objOlNamespace As Object
                Dim objOlFolder As Object
                
                objOutlook = CreateObject("Outlook.Application") ' create outlook application object at the run time
                objOlNamespace = objOutlook.GetNamespace("MAPI")
                objOlFolder = objContactsNS.PickFolder ' displays the folder dialog
                Last edited by Niheel; Jun 2 '10, 01:58 PM. Reason: Added code tags to post. We don't allow signatures in posts. Sorry :)

                Comment

                Working...