By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,871 Members | 2,444 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,871 IT Pros & Developers. It's quick & easy.

open folder from access

P: 68
I would like to open a folder from command button and I am not having any luck;
Expand|Select|Wrap|Line Numbers
  1. ...
  2.   Dim stdfile as string
  3.   open stdfile "c:\temp"
  4. 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
Mar 12 '08 #1
Share this Question
Share on Google+
7 Replies


Scott Price
Expert 100+
P: 1,384
What do you mean: Open?

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

Regards,
Scott
Mar 13 '08 #2

P: 68
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
Mar 13 '08 #3

Scott Price
Expert 100+
P: 1,384
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
Mar 13 '08 #4

P: 68
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 :
Expand|Select|Wrap|Line Numbers
  1.  Me.Body = Me.Body & vbCrLf & locmsg & savefile & FileName & SeqNum & "." & Extension & vbNewLine
  2.  
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 :
Expand|Select|Wrap|Line Numbers
  1.  Len ( FileName&SeqNum) = 1 Then
  2.    .show
  3.  
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
Mar 14 '08 #5

Scott Price
Expert 100+
P: 1,384
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:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command2_Click()
  2.  
  3. Const conVerticalOnly As Integer = 2
  4. 'Dim fsoSysObj As FileSystemObject
  5. Dim fd As FileDialog, strFilesSelected As String, blnRetVal As Boolean
  6.  
  7. Set fd = Application.FileDialog(msoFileDialogFilePicker)
  8.  
  9. 'Declare a variable to contain the path, it must be a Variant becase
  10. 'the For ... Each construct requires it
  11. Dim vrtSelectedItem As Variant
  12.  
  13. Restart:
  14.  
  15. With fd
  16.     .AllowMultiSelect = False
  17.     .Title = "Browse Files"
  18.         If .Show = -1 Then
  19.             For Each vrtSelectedItem In .SelectedItems
  20.                 If Left(vrtSelectedItem, 15) <> "D:\Access Code\" Then
  21.                     MsgBox "Please select a valid path."
  22.                     GoTo Restart:
  23.                 End If
  24.             'Now, will only be one since MultiSelect = False
  25.             strFilesSelected = vrtSelectedItem
  26.             blnRetVal = Execute_Program(strFilesSelected, "", "")
  27.             Next vrtSelectedItem
  28.         Else
  29.         'The user pressed Cancel
  30.         End If
  31. End With
  32.  
  33. Set fd = Nothing
  34.  
  35. Me!Text0.ScrollBars = conVerticalOnly
  36. Me!Text0 = strFilesSelected
  37.  
  38. End Sub
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
Mar 14 '08 #6

Scott Price
Expert 100+
P: 1,384
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
Mar 14 '08 #7

P: 1
@Trevor2007
Following is the code sample used to display the outlook folder dialog using VB.NET
Expand|Select|Wrap|Line Numbers
  1. Dim objOutlook As Object
  2. Dim objOlNamespace As Object
  3. Dim objOlFolder As Object
  4.  
  5. objOutlook = CreateObject("Outlook.Application") ' create outlook application object at the run time
  6. objOlNamespace = objOutlook.GetNamespace("MAPI")
  7. objOlFolder = objContactsNS.PickFolder ' displays the folder dialog
  8.  
Jun 2 '10 #8

Post your reply

Sign in to post your reply or Sign up for a free account.