Full Version: Run a programm from access
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
Hello world!!
want to fire a program in command line and i dont know how (???)
Owant to simply locate it (in the pre-configured location) and then fire it with the parameters for the job i want to do..
for example, i want to rename a file
Can any body help me?
thanks for your time..
There are a number of built-in statements that can be used for file handling:
Name rename or move a file or folder
Kill delete a file
FileCopy copy files

Check the help file for exact syntax.

For starting other program from Access, read about the Shell function. If you want to open document read about the FollowHyperlink method.

Hope this helps.
Bo Melin
ok, thanks for your answer, but i dont want to use the build in function.
want to learn the way i can use external utilities from access.
Omean, how can i build the command in vba code to run the programm i want.
thanks again
Try looking at the Shell function, as stated by Bo.
These are the options I use depending on the situation in each case:
hell function : Start a program but do not wait for it to finish
Shell and Wait : Start an application and wait for it to finish
Start an app with ShellExecute : Open or print a file with the associated application
FollowHyperlink method : open a document or web page speciified by a hyperlink adress
Bo Melin
ok, this is the solution, but, how can i use the shell and wait ?
For exable, i want to run this in shell
RARCommandLine = "c:\windows\rar.exe e -hpCharsetxx_MehKGyZM9ZnG " & OnomaArxeiouRAR
EktelesiRAR = Shell(RARCommandLine, vbHide)

the call of shell and wait, where must be placed?
before the fire of rar.exe, after, where?
can you please tell me?
Use the code from the link I posted and then use
ARCommandLine = "c:\windows\rar.exe e -hpCharsetxx_MehKGyZM9ZnG " & OnomaArxeiouRAR
Call ShellWait(RARCommandLine, vbHide)
Bo Melin
ok, i run it, but my app is freeze!!
. i have made a module of the link you send me.
2. i (want) to run the follwing code
Private Sub import_tables_Click()
Dim RARCommandLine As String
Dim EktelesiRAR As String
Dim OnomaArxeiouRAR As String
Dim OnomaArxeiouMDB As String
OnomaArxeiouRAR = Me.txtFileToOpen
RARCommandLine = "c:\windows\rar.exe e -hpCharsetxx_MehKGyZM9ZnG " & OnomaArxeiouRAR
EktelesiRAR = Shell(RARCommandLine, vbHide)
Call ShellWait(RARCommandLine, vbHide)
'dimiourgia onomatos mdb
OnomaArxeiouMDB = Me.txtFileToOpen
OnomaArxeiouMDB = StrReverse(OnomaArxeiouMDB)
OnomaArxeiouMDB = Replace(OnomaArxeiouMDB, "rps", "bdm", , 1)
OnomaArxeiouMDB = StrReverse(OnomaArxeiouMDB)
'eisagogi pinakon
   'On Error GoTo ErrHandler
   Dim db As Database
   Dim tbl As TableDef
   Dim sPath As String
   Dim sTblName As String
   Dim sLinkedTblName As String
   Dim fOpenedDB As Boolean
   sPath = OnomaArxeiouMDB
   sTblName = "tblergasies"
   sLinkedTblName = "tblergasies_Link"
    If ObjectExists("Table", sLinkedTblName) Then
    DoCmd.DeleteObject acTable, sLinkedTblName
    End If
   Set db = CurrentDb()
   fOpenedDB = True
   Set tbl = db.CreateTableDef(sLinkedTblName, _
       dbAttachSavePWD, sTblName, ";Database=" & sPath & _
   db.TableDefs.Append tbl
   Exit Sub
   Set tbl = Nothing
   If (fOpenedDB) Then
       fOpenedDB = False
   End If
End Sub

what am i doing here?
I have a rar compressed file with an mdb inside. (the rar file is secured)
i must 1st decompress the rar file, then read the mdb file and link the tables in my main app.
the code is working (if i run it in steps), but it must find the extracted mdb file, and it cant because the access cant wait for extraction first....
so, i must use something like those you show me, but i cant make it work..
any help?
You are running the RAR application twice and they are probably blocking each other. Remove
ktelesiRAR = Shell(RARCommandLine, vbHide)
Bo Melin
i dont thing i am running the rar twice, only in the EktelesiRAR = Shell(RARCommandLine, vbHide) i am using run command...
hey, look what i found...
another method of wait for an application
I think you should stick to what Bo said... He's right about this, you should remove the line he mentioned, and you'll be alright!
You have this in your code
ARCommandLine = "c:\windows\rar.exe e -hpCharsetxx_MehKGyZM9ZnG " & OnomaArxeiouRAR
EktelesiRAR = Shell(RARCommandLine, vbHide)
Call ShellWait(RARCommandLine, vbHide)
You are running the RAR twice. It should be
RARCommandLine = "c:\windows\rar.exe e -hpCharsetxx_MehKGyZM9ZnG " & OnomaArxeiouRAR
Call ShellWait(RARCommandLine, vbHide)
Bo Melin
ok, ok, i see..
will try it and i will tell you..
now i must go for an outdoor work and i will return in 2 or 3 ours..
thanks for all...
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.