Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script.Shell directory search 1

Status
Not open for further replies.

Penrodcigar

Technical User
Aug 23, 2006
19
0
0
US
Dim S As Object
Set S = CreateObject("WScript.Shell")
S.Run Chr(34) & "C:\01_LawSchool\12 Spring 2007\Independent study\Data zoning exceptions 2000-2004\2000 vol I\HPIM3948.JPG" & Chr(34)
Set S = Nothing

I'm using the above code to open scans with a command button on a form. But the directory seems to long. I can't copy the files to another computer and get it to work without rewriting the code. I remember in the old days of the the Autocad/Autolisp help forum on Compuserve, there was a way to put [scan] files in the same directory as [the database]and they would open. The software would find the files as long as they were in the same directory. Can this be done with Access?

Thanks,
 
You need to specify the application, use FollowHyperlink or use the code below from Open A Document Using Registered Application With Minimal Code: faq222-2066

1. An Example with Paint
Code:
Set S = CreateObject("WScript.Shell")
S.Run """C:\WINDOWS\system32\mspaint.exe"" ""C:\01_LawSchool\12 Spring 2007\Independent study\Data zoning exceptions 2000-2004\2000 vol I\HPIM3948.JPG"""

2. FollowHyperlink
Code:
FollowHyperlink "C:\01_LawSchool\12 Spring 2007\Independent study\Data zoning exceptions 2000-2004\2000 vol I\HPIM3948.JPG"

3. faq222-2066
Code:
Public Sub OpenDocument()
Dim A As Long
DocPath = "C:\01_LawSchool\12 Spring 2007\Independent study\Data zoning exceptions 2000-2004\2000 vol I\HPIM3948.JPG"
A = Shell("RUNDLL32.EXE URL.DLL,FileProtocolHandler " & DocPath, vbMaximizedFocus)
End Sub

Finally, you can cause the picture to appear in an image control on your form. It takes a little code, which can be found here:
 
Yes but, when the scan files (and database) are copied to another computer the paths will change...
 
One way to get round this is to store just the subdirectory and file name, the rest of the path can be obtained by looking up a table or, if the subdirectory is in the same folder as the database, by using currentproject.path.

What would you like to see happening?
 
...I knew I would get a difficult philosophical question...it's for the kids of course...thanks
 
Ok. The easiest thing to do is to put everything in a specific folder that will move from computer to computer, say:

[tt]KidFolder
- KidAPhotos
- KidAStudyDocs[/tt]

Store in your database table:

[tt]\KidFolder\KidAPhotos\Photo1.jpg
\KidFolder\KidAStudyDocs\Doc1.doc[/tt]

Code for the Double-Click event of the file name, or a suitable command button, say:

[tt]FollowHyperLink "C:\Documents and Settings\" & Me.FileName[/tt]

FollowHyperlink will open each file with its registered application.

This would be suitable for a business, but may suit a home set-up.


 
Ramou...how about the possibility of a defined series of 2 or 3 images operated from a form control? If all the images are in a single directory and the Access control shells out to a particular image in the directory, the rest of the images will appear in sequence after it. I would prefer if the shell-out could be restricted to a set of 2 or 3 images for viewing in relation to the data. Any ideas? I think this requires more control of the Microsoft photo/fax viewer than I am capeable of.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top