Shell command with variables

emillard

New member
Local time
Today, 21:28
Joined
Feb 7, 2001
Messages
9
I like experimenting with VBA in Access2000, but I'm still mind boggled by quite a bit of it all. I posted a question regarding runapp for opening an application and showing contracts that have been scanned in. Mike G showed me the shell command. That works great, but I'm having a hard time with the variable part. Of the file path, one piece changes based on the value of the field on the current form. ie. the form shows a contract number 1002 in the field jobcontractno - I want to open on drive D, the archive folder, the folder #1002, then the active folder, and finally the images. That middle part that is always changing has me going in circles. Any help would be great. Thanks, Emily
 
Don't know if you're still battling with this one, but I had a similar problem; I can't always get the Shell command to work properly with command-line parameters:

Dim strTemp As String
strTemp = "c:\Myprog.exe Parameter1 parameter2"
Shell StrTemp

just doesn't work for some apps (don't know why not)

My workaround involved creating a batch file and running that, so, something like:

Dim strTemp As String
strTemp = "c:\Myprog.exe Parameter1 parameter2"
Open "c:\tempBat.bat" For Output As #1
Print# 1, strTemp
Close# 1
Doevents
Shell "c:\tempBat.bat"

It's a bit of a fiddle to do it this way, but it seems to work more reliably.

Mike
 
I'm not as familiar with Access 2K yet as I would like to be, but the problem you described (and Mike's reply) tell me that there is a difference in the context between the shell command and a batch environment.

That usually means that an input or output channel has not been properly established and the app seems to require it. Either that, or the directory context is wrong one way but right the other way.

Don't know if that helps or hinders, but that is how I would interpret the situation.
 
I do not know whether this information might help you, but I found a very elegant solution for these path-filename-related problems.
One of my clients (lawyer) wanted to manage his Word-files with ACCESS.
Another (office with more than 50 architects) wanted to manage AUTOCAD files.
Several clients have large numbers of graphic files (mainly photos) that need to be classified and managed by a database.
Our (classical) solution was just in saving the path/filenames and opening the files with a SHELL command. This worked well, but we (or better our clients) had permanently problems with the location of these files. A nightmare.
So we looked for another solution and we finally tried to find some 3rd party software that is both specialized in ACCESS and in the a.m.file formats. It was difficult but we found a professional solution on www.SWREG.ORG (for example WORD! WITH ACCESS, AUTOCAD! WITH ACCESS). If I compare now the prize we paid with the number of hours we invested before to find an own solution I realize that should have made this investment much earlier.
 

Users who are viewing this thread

Back
Top Bottom