473,786 Members | 2,571 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Search a specific directory on a specific drive

I have been trying to edit the Explorer example by Dev Ashish I found
on www.msvp.org (I think). I have been all over the net so I am not
quite sure where the file came from.
I like the way it works but I can not find a way to tell it to display
a certain directory. I want it to display a folder on our share drive.
I know the path for the directory. I want users to be able to open any
files below the parent directory I tell it to start in.
So, I don't want to to search for all the drives on the user's
computer.
I am very new to programming in VB and need detailed instructions if
possible.
There are 4 modules and a form. I know it is best to post the code but
since it is so long I tought I would ask which module I should post
instead of posting them all.
Oh, I am using MS Access 2002. The files I want to access are on the
shared drive with the database (different directory).
Let me know if more information is required. I will look for the web
site where I downloaded the files and post it here. Until then, any
help would be appreciated.
Thanks in advance.
Nov 13 '05 #1
6 1872
I use AK2 and have a table "Paths" that holds paths to various things that
might be of interest in that database such as where the backend is stores,
where the photos are stored, where the help file is etc.

The routine for looking for a file or directory starts from the location
found in paths and opens the directory open dialogue box.
Nicked from various sources

Can probably send something if you are interested

Phil
"E Pease" <go****@thaiam. com> wrote in message
news:a1******** *************** ***@posting.goo gle.com...
I have been trying to edit the Explorer example by Dev Ashish I found
on www.msvp.org (I think). I have been all over the net so I am not
quite sure where the file came from.
I like the way it works but I can not find a way to tell it to display
a certain directory. I want it to display a folder on our share drive.
I know the path for the directory. I want users to be able to open any
files below the parent directory I tell it to start in.
So, I don't want to to search for all the drives on the user's
computer.
I am very new to programming in VB and need detailed instructions if
possible.
There are 4 modules and a form. I know it is best to post the code but
since it is so long I tought I would ask which module I should post
instead of posting them all.
Oh, I am using MS Access 2002. The files I want to access are on the
shared drive with the database (different directory).
Let me know if more information is required. I will look for the web
site where I downloaded the files and post it here. Until then, any
help would be appreciated.
Thanks in advance.

Nov 13 '05 #2
E P


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3
E P
Thanks. I would like to try that. It sounds like a good solution to my
problem since I think there will be more instances when I will need to
have users open a file on the shared drive. Please send a URL to the
download site. Is it free? Are there any known problems in setting it
up?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #4
OK. I did not understand that AK2 was Access 2002.
Nov 13 '05 #5
I am very interested in anything you can send. I will try to create a
table with the paths now.

E P <de***********@ thaiam.com> wrote in message news:<41******* *************** @news.newsgroup s.ws>...
Thanks. I would like to try that. It sounds like a good solution to my
problem since I think there will be more instances when I will need to
have users open a file on the shared drive. Please send a URL to the
download site. Is it free? Are there any known problems in setting it
up?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 13 '05 #6
OK. I found another script and got the module to start in the
directory I want BUT it does not open the file once I double click on
the name. It just closes the browsing window. I have pasted the code I
am using below.
Where and how do I set it to open the file I select using its default
application?

Thanks in advance.
~~~~~~~~~~~~~~~ ~~~~~~Code Starts Here ~~~~~~~~~~~~~~~ ~~~
Option Compare Database
Option Explicit

'API: Call the standard Windows File Open/Save dialog box
'Paste the following code in a new module
'************** *** Code Start **************
'This code was originally written by Ken Getz.
'It is not to be altered or distributed, except as part of an
application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
'
' Code courtesy of:
' Microsoft Access 95 How-To
' Ken Getz and Paul Litwin
' Waite Group Press, 1996

Type tagOPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
strFilter As String
strCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
strFile As String
nMaxFile As Long
strFileTitle As String
nMaxFileTitle As Long
strInitialDir As String
strTitle As String
Flags As Long
nFileOffset As Integer
nFileExtension As Integer
strDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Declare Function aht_apiGetOpenF ileName Lib "comdlg32.d ll" _
Alias "GetOpenFileNam eA" (OFN As tagOPENFILENAME ) As Boolean
Declare Function aht_apiGetSaveF ileName Lib "comdlg32.d ll" _
Alias "GetSaveFileNam eA" (OFN As tagOPENFILENAME ) As Boolean
Declare Function CommDlgExtended Error Lib "comdlg32.d ll" () As Long
Global Const ahtOFN_READONLY = &H1
Global Const ahtOFN_OVERWRIT EPROMPT = &H2
Global Const ahtOFN_HIDEREAD ONLY = &H4
Global Const ahtOFN_NOCHANGE DIR = &H8
Global Const ahtOFN_SHOWHELP = &H10
' You won't use these.
'Global Const ahtOFN_ENABLEHO OK = &H20
'Global Const ahtOFN_ENABLETE MPLATE = &H40
'Global Const ahtOFN_ENABLETE MPLATEHANDLE = &H80
Global Const ahtOFN_NOVALIDA TE = &H100
Global Const ahtOFN_ALLOWMUL TISELECT = &H200
Global Const ahtOFN_EXTENSIO NDIFFERENT = &H400
Global Const ahtOFN_PATHMUST EXIST = &H800
Global Const ahtOFN_FILEMUST EXIST = &H1000
Global Const ahtOFN_CREATEPR OMPT = &H2000
Global Const ahtOFN_SHAREAWA RE = &H4000
Global Const ahtOFN_NOREADON LYRETURN = &H8000
Global Const ahtOFN_NOTESTFI LECREATE = &H10000
Global Const ahtOFN_NONETWOR KBUTTON = &H20000
Global Const ahtOFN_NOLONGNA MES = &H40000
' New for Windows 95
Global Const ahtOFN_EXPLORER = &H80000
Global Const ahtOFN_NODEREFE RENCELINKS = &H100000
Global Const ahtOFN_LONGNAME S = &H200000
Function TestIt()
Dim strFilter As String
Dim lngFlags As Long
strFilter = ahtAddFilterIte m(strFilter, "Access Files (*.mda, *.mdb)",
_
"*.MDA;*.MD B")
strFilter = ahtAddFilterIte m(strFilter, "dBASE Files (*.dbf)",
"*.DBF")
strFilter = ahtAddFilterIte m(strFilter, "Text Files (*.txt)", "*.TXT")
strFilter = ahtAddFilterIte m(strFilter, "All Files (*.*)", "*.*")
MsgBox "You selected: " & ahtCommonFileOp enSave(InitialD ir:="C:\", _
Filter:=strFilt er, FilterIndex:=3, Flags:=lngFlags , _
DialogTitle:="H ello! Open Me!")
' Since you passed in a variable for lngFlags,
' the function places the output flags value in the variable.
Debug.Print Hex(lngFlags)
End Function

Function GetOpenFile(Opt ional varDirectory As Variant, _
Optional varTitleForDial og As Variant) As Variant
' Here's an example that gets an Access database name.
Dim strFilter As String
Dim lngFlags As Long
Dim varFileName As Variant
' Specify that the chosen file must already exist,
' don't change directories when you're done
' Also, don't bother displaying
' the read-only box. It'll only confuse people.
lngFlags = ahtOFN_FILEMUST EXIST Or _
ahtOFN_HIDEREAD ONLY Or ahtOFN_NOCHANGE DIR
If IsMissing(varDi rectory) Then
varDirectory = ""
End If
If IsMissing(varTi tleForDialog) Then
varTitleForDial og = ""
End If

' Define the filter string and allocate space in the "c"
' string Duplicate this line with changes as necessary for
' more file templates.
strFilter = ahtAddFilterIte m(strFilter, _
"Access (*.mdb)", "*.MDB;*.MD A")
' Now actually call to get the file name.
varFileName = ahtCommonFileOp enSave( _
OpenFile:=True, _
InitialDir:=var Directory, _
Filter:=strFilt er, _
Flags:=lngFlags , _
DialogTitle:=va rTitleForDialog )
If Not IsNull(varFileN ame) Then
varFileName = TrimNull(varFil eName)
End If
GetOpenFile = varFileName
End Function
Function ahtCommonFileOp enSave( _
Optional ByRef Flags As Variant, _
Optional ByVal InitialDir As Variant, _
Optional ByVal Filter As Variant, _
Optional ByVal FilterIndex As Variant, _
Optional ByVal DefaultExt As Variant, _
Optional ByVal FileName As Variant, _
Optional ByVal DialogTitle As Variant, _
Optional ByVal hwnd As Variant, _
Optional ByVal OpenFile As Variant) As Variant
' This is the entry point you'll use to call the common
' file open/save dialog. The parameters are listed
' below, and all are optional.
'
' In:
' Flags: one or more of the ahtOFN_* constants, OR'd together.
' InitialDir: the directory in which to first look
' Filter: a set of file filters, set up by calling
' AddFilterItem. See examples.
' FilterIndex: 1-based integer indicating which filter
' set to use, by default (1 if unspecified)
' DefaultExt: Extension to use if the user doesn't enter one.
' Only useful on file saves.
' FileName: Default value for the file name text box.
' DialogTitle: Title for the dialog.
' hWnd: parent window handle
' OpenFile: Boolean(True=Op en File/False=Save As)
' Out:
' Return Value: Either Null or the selected filename
Dim OFN As tagOPENFILENAME
Dim strFileName As String
Dim strFileTitle As String
Dim fResult As Boolean
' Give the dialog a caption title.
If IsMissing(Initi alDir) Then InitialDir = "CurDir"
If IsMissing(Filte r) Then Filter = ""
If IsMissing(Filte rIndex) Then FilterIndex = 1
If IsMissing(Flags ) Then Flags = 0&
If IsMissing(Defau ltExt) Then DefaultExt = ""
If IsMissing(FileN ame) Then FileName = ""
If IsMissing(Dialo gTitle) Then DialogTitle = ""
If IsMissing(hwnd) Then hwnd = Application.hWn dAccessApp
If IsMissing(OpenF ile) Then OpenFile = True
' Allocate string space for the returned strings.
strFileName = Left(FileName & String(256, 0), 256)
strFileTitle = String(256, 0)
' Set up the data structure before you call the function
With OFN
..lStructSize = Len(OFN)
..hwndOwner = hwnd
..strFilter = Filter
..nFilterIndex = FilterIndex
..strFile = strFileName
..nMaxFile = Len(strFileName )
..strFileTitle = strFileTitle
..nMaxFileTitle = Len(strFileTitl e)
..strTitle = DialogTitle
..Flags = Flags
..strDefExt = DefaultExt
..strInitialDir = InitialDir
' Didn't think most people would want to deal with
' these options.
..hInstance = 0
..strCustomFilt er = ""
..nMaxCustFilte r = 0
..lpfnHook = 0
'New for NT 4.0
..strCustomFilt er = String(255, 0)
..nMaxCustFilte r = 255
End With
' This will pass the desired data structure to the
' Windows API, which will in turn it uses to display
' the Open/Save As Dialog.
If OpenFile Then
fResult = aht_apiGetOpenF ileName(OFN)
Else
fResult = aht_apiGetSaveF ileName(OFN)
End If

' The function call filled in the strFileTitle member
' of the structure. You'll have to write special code
' to retrieve that if you're interested.
If fResult Then
' You might care to check the Flags member of the
' structure to get information about the chosen file.
' In this example, if you bothered to pass in a
' value for Flags, we'll fill it in with the outgoing
' Flags value.
If Not IsMissing(Flags ) Then Flags = OFN.Flags
ahtCommonFileOp enSave = TrimNull(OFN.st rFile)
Else
ahtCommonFileOp enSave = vbNullString
End If
End Function
Function ahtAddFilterIte m(strFilter As String, _
strDescription As String, Optional varItem As Variant) As String
' Tack a new chunk onto the file filter.
' That is, take the old value, stick onto it the description,
' (like "Databases" ), a null character, the skeleton
' (like "*.mdb;*.md a") and a final null character.

If IsMissing(varIt em) Then varItem = "*.*"
ahtAddFilterIte m = strFilter & _
strDescription & vbNullChar & _
varItem & vbNullChar
End Function
Private Function TrimNull(ByVal strItem As String) As String
Dim intPos As Integer
intPos = InStr(strItem, vbNullChar)
If intPos > 0 Then
TrimNull = Left(strItem, intPos - 1)
Else
TrimNull = strItem
End If
End Function
'************** Code End *************** **

Sub Just_More_Notes ()
'To call the actual dialog from your code, see the enclosed function
TestIt()
'within the module or use the following example as a guideline and
Dim strFilter As String
Dim strInputFileNam e As String

strFilter = ahtAddFilterIte m(strFilter, "Excel Files (*.XLS)",
"*.XLS")
strInputFileNam e = ahtCommonFileOp enSave(Filter:= strFilter,
OpenFile:=True, _
DialogTitle:="P lease select an input file...", _
Flags:=ahtOFN_H IDEREADONLY)

'Note that in order to call the Save As dialog box,you can use the
'same wrapper function by just setting the OpenFile option as False.
For example,

'Ask for SaveFileName
strFilter = ahtAddFilterIte m(myStrFilter, "Excel Files (*.xls)",
"*.xls")
strSaveFileName = ahtCommonFileOp enSave(OpenFile :=False,
Filter:=strFilt er, _
Flags:=ahtOFN_O VERWRITEPROMPT Or ahtOFN_READONLY )
End Sub

Function OpenDocRepos(Op tional varDirectory As Variant) As Variant
Dim strFilter As String, lngFlags As Long, varFileName As Variant

lngFlags = ahtOFN_FILEMUST EXIST Or _
ahtOFN_HIDEREAD ONLY Or ahtOFN_NOCHANGE DIR
If IsMissing(varDi rectory) Then
varDirectory = ""
End If
' you can choose to add a number of file extensions which will appear
in the drop down Files of Type box
' strFilter = ahtAddFilterIte m(strFilter, "Text files (*.txt)",
"*.txt")
strFilter = ahtAddFilterIte m(strFilter, "Any files (*.*)", "*.*")
varFileName = ahtCommonFileOp enSave( _
OpenFile:=True, _
InitialDir:="\\ Server1.tdfinan cial.local\home option\DOCUMENT
REPOSITORY", _
Filter:=strFilt er, _
Flags:=lngFlags , _
DialogTitle:="C hose a file ...") ' < This is the title to your dialog
box
If Not IsNull(varFileN ame) Then
varFileName = TrimNull(varFil eName)
End If
OpenDocRepos = varFileName
End Function
~~~~~~~~~~~~~~~ ~~~~~~Code Ends Here ~~~~~~~~~~~~~~~ ~~~
Nov 13 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2364
by: Peter Schwalm | last post by:
I'd like to modify the python search path depending on the source directory of the script being started. The reason is: I use a version control system, and the python scripts and modules are migrated through several stages before they are used in production. A python script running in a development environment should use different modules - possibly in other directories then the script source directory - than the same script running in a...
1
1479
by: MP | last post by:
I was wondering if anyone can point me to some example code of searching for a file, like *.*, or *.pdf, much like the Windows search function. I am at a smaller location, away from the main office, and although I can map a drive or just use \\ to go to the desired location, the connection is too slow to search. I'd like to implement a search function on the intranet web (at the main office), where it will search a certain directory...
3
6814
by: KSC | last post by:
Hello, Is there a way to programmatically determine if a directory is shared and if so, what the sharename is? It seems a simple question, but I have been searching and not found the answer... Thanks in advance!
16
2862
by: Computer geek | last post by:
Hello, I am new to VB.NET and programming in general. I have taught myself a lot of the basics with vb.net but am still quite the novice. I am working on a little application now and I need some help with one part of the code. When a button is clicked I need to have it go out to a network drive location and count how many files are present with a certain file extension. Then store that number in a declared variable. Is this possible? Can...
2
1076
by: pa2ratczi | last post by:
Hi there, am having trouble with my program, its a file locator program just like a search engine in a local drive: heres wat i have coded: Private Sub Command1_Click() Dim SearchFile As String Dim FileName As String If Drive1.Drive = "c:" Then SearchFile = Dir$("C:\*.*") While SearchFile <> ""
4
2515
by: ravindarjobs | last post by:
hi...... i am using ms access 2003,vb6 i have a form. in that i have 2 buttons 1. start search 2 stop search when i click the "start search" button the fucntion SearchSystem() is called, it will search for a particular file in the computer(searches entire drives).
2
1973
by: princymg | last post by:
I want to search a file from server and want to copy it to the local disk. how it is done? This is working if the file is in my hard disk itself.But not when it comes to server. If i map the server i can search.like y:\\serverfolde\\folder am tring to make an exe. different people will map to different drive. so i cant give like that.should give like @\\server\\serverfolde\\folder\\ but it is not working. My code is<code>...
2
1691
by: princymg | last post by:
I want to search a file from server and want to copy it to the local disk. how it is done? This is working if the file is in my hard disk itself.But not when it comes to server. If i map the server i can search.like y:\\serverfolde\\folder am tring to make an exe. different people will map to different drive. so i cant give like that.should give like @\\server\\serverfolde\\folder\\ but it is not working. My code is...
0
10784
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not a new concept, there is a concept called Steganography which enables to conceal your secret...
0
9650
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8992
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6748
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.