My Assistant
![]() ![]() |
|
|
Jul 25 2006, 06:05 AM
Post
#1
|
|
|
UtterAccess Addict Posts: 145 From: Hellas (Greece) |
Hello world!!
i want to fire a program in command line and i dont know how (???) i want 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.. |
|
|
|
Jul 25 2006, 06:16 AM
Post
#2
|
|
|
UtterAccess VIP Posts: 1,644 From: Sweden |
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 |
|
|
|
Jul 25 2006, 06:32 AM
Post
#3
|
|
|
UtterAccess Addict Posts: 145 From: Hellas (Greece) |
ok, thanks for your answer, but i dont want to use the build in function.
i want to learn the way i can use external utilities from access. i mean, how can i build the command in vba code to run the programm i want. thanks again |
|
|
|
Jul 25 2006, 07:52 AM
Post
#4
|
|
|
Utter A-fishin'-ado Posts: 17,723 From: Cincinnati, Ohio, USA . . . ><((((°> |
Try looking at the Shell function, as stated by Bo.
|
|
|
|
Jul 25 2006, 08:24 AM
Post
#5
|
|
|
UtterAccess VIP Posts: 1,644 From: Sweden |
These are the options I use depending on the situation in each case:
Shell 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 |
|
|
|
Jul 26 2006, 05:27 AM
Post
#6
|
|
|
UtterAccess Addict Posts: 145 From: Hellas (Greece) |
ok, this is the solution, but, how can i use the shell and wait ?
for exable, i want to run this in shell CODE 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? |
|
|
|
Jul 26 2006, 05:36 AM
Post
#7
|
|
|
UtterAccess VIP Posts: 1,644 From: Sweden |
Use the code from the link I posted and then use
RARCommandLine = "c:\windows\rar.exe e -hpCharsetxx_MehKGyZM9ZnG " & OnomaArxeiouRAR Call ShellWait(RARCommandLine, vbHide) ___________ Bo Melin |
|
|
|
Jul 26 2006, 06:03 AM
Post
#8
|
|
|
UtterAccess Addict Posts: 145 From: Hellas (Greece) |
ok, i run it, but my app is freeze!!
1. i have made a module of the link you send me. 2. i (want) to run the follwing code 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 & _ ";Pwd=MyPswd") db.TableDefs.Append tbl Exit Sub Set tbl = Nothing If (fOpenedDB) Then db.Close 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? |
|
|
|
Jul 26 2006, 06:08 AM
Post
#9
|
|
|
UtterAccess VIP Posts: 1,644 From: Sweden |
You are running the RAR application twice and they are probably blocking each other. Remove
EktelesiRAR = Shell(RARCommandLine, vbHide) ____________ Bo Melin |
|
|
|
Jul 26 2006, 06:25 AM
Post
#10
|
|
|
UtterAccess Addict Posts: 145 From: Hellas (Greece) |
i dont thing i am running the rar twice, only in the EktelesiRAR = Shell(RARCommandLine, vbHide) i am using run command...
|
|
|
|
Jul 26 2006, 06:27 AM
Post
#11
|
|
|
UtterAccess Addict Posts: 145 From: Hellas (Greece) |
hey, look what i found...
another method of wait for an application |
|
|
|
Jul 26 2006, 06:34 AM
Post
#12
|
|
|
UtterAccess Ruler Posts: 2,197 From: Den Bosch - Netherlands |
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!
|
|
|
|
Jul 26 2006, 06:34 AM
Post
#13
|
|
|
UtterAccess VIP Posts: 1,644 From: Sweden |
You have this in your code
RARCommandLine = "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 |
|
|
|
Jul 26 2006, 06:45 AM
Post
#14
|
|
|
UtterAccess Addict Posts: 145 From: Hellas (Greece) |
ok, ok, i see..
i 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... |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 26th May 2013 - 01:36 AM |