[AccessD] CmdRunApp Help

John W. Colby jcolby at colbyconsulting.com
Thu Dec 11 10:19:21 CST 2003


Always welcome.

As you can no doubt tell, I love the FSO.  Having an object to program
allows us to do anything that the File system allows right from within
Access.  Set file properties, change names, move things around, add / delete
folders.  AFAICT, if you can do it from Explorer, you can do it from the
FSO.  Plus you have intellisense to prompt you as to the properties and
methods, parameters needed etc.

Way cool.

John W. Colby
www.ColbyConsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Gowey Mike W
Sent: Thursday, December 11, 2003 11:06 AM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] CmdRunApp Help


John,

Thanks very much for your help, this works absolutely wonderful and does
exactly what I needed it to do.  So slick.....

You're the man....thanks again,


Mike Gowey, MCSA, A+
Team Leader - SRCI
Information Systems & Services Division


-----Original Message-----
From: John W. Colby [mailto:jcolby at colbyconsulting.com]
Sent: Tuesday, December 09, 2003 1:11 PM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] CmdRunApp Help


why don't you just do it from within Access?  If the filesystem object
is accessible, reference it.  Then:

Function CopyFile(strFileName As String, strDestDir As String) As
Boolean On Error GoTo Err_CopyFile Dim fs As FileSystemObject
    Set fs = CreateObject("Scripting.FileSystemObject")
    'On Error Resume Next
    'if the file doesn't exist, ignore the error
    fs.CopyFile strFileName, strDestDir
    CopyFile = True
Exit_CopyFile:
On Error Resume Next
    Set fs = Nothing
Exit Function
Err_CopyFile:
        MsgBox Err.Description, , "Error in Sub basUtils.CopyFile"
        Resume Exit_CopyFile
    Resume 0    '.FOR TROUBLESHOOTING
End Function
Sub DeleteFile(strFileName As String)
On Error GoTo Err_DeleteFile
Dim fs As FileSystemObject
    Set fs = CreateObject("Scripting.FileSystemObject")
    On Error Resume Next
    'if the file doesn't exist, ignore the error
    fs.DeleteFile strFileName
Exit_DeleteFile:
On Error Resume Next
    Set fs = Nothing
Exit Sub
Err_DeleteFile:
    Select Case Err
    Case 0      '.insert Errors you wish to ignore here
        Resume Next
    Case Else   '.All other errors will trap
        Beep
        MsgBox Err.Description, , "Error in Sub basUtils.DeleteFile"
        Resume Exit_DeleteFile
    End Select
    Resume 0    '.FOR TROUBLESHOOTING
End Sub
Sub RenameFile(strFileName As String, strNewName As String)
On Error GoTo Err_RenameFile
    Dim fs As FileSystemObject
    Dim f As File
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFile(strFileName)
    f.Name = strNewName
Exit_RenameFile:
On Error Resume Next
    Set f = Nothing
    Set fs = Nothing
Exit Sub
Err_RenameFile:
    Select Case Err
    Case 0      '.insert Errors you wish to ignore here
        Resume Next
    Case Else   '.All other errors will trap
        Beep
        MsgBox Err.Description, , "Error in Sub basUtils.RenameFile"
        Resume Exit_RenameFile
    End Select
    Resume 0    '.FOR TROUBLESHOOTING
End Sub
'.Comments  :
'.Parameters:
'.Created by: John W. Colby
'.Created   : 12/5/2002 9:29:43 PM
Sub CreateDir(strPath As String)
On Error GoTo Err_CreateDir
Dim fs As FileSystemObject
    Set fs = CreateObject("Scripting.FileSystemObject")
    On Error Resume Next
    'if the file doesn't exist, ignore the error
    fs.CreateFolder strPath
Exit_CreateDir:
On Error Resume Next
    Set fs = Nothing
Exit Sub
Err_CreateDir:
    Select Case Err
    Case 0      '.insert Errors you wish to ignore here
        Resume Next
    Case Else   '.All other errors will trap
        Beep
        MsgBox Err.Description, , "Error in Sub basUtils.CreateDir"
        Resume Exit_CreateDir
    End Select
    Resume 0    '.FOR TROUBLESHOOTING
End Sub

John W. Colby
www.ColbyConsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Gowey Mike W
Sent: Tuesday, December 09, 2003 3:03 PM
To: Access Developers discussion and problem solving
Subject: [AccessD] CmdRunApp Help



Hello all,

I have within my database a call to run a batch program that takes a
file that resides on one of our Network servers and copies it to our
local server and renames it to a text file.  I than take that text file
and import it into a table.

My question is, is there a way to call the batch program and have it run
in the background or run minimized.  Right now it works but the dos
window comes up over the top of the database and does the copy and
rename in other words runs in the foreground.

I have a progress meter that comes up that I would like the user to see
rather than the ugly little black dos window.

Thanks in advance for any advice.


Mike Gowey, MCSA, A+
Team Leader - SRCI
Information Systems & Services Division





More information about the AccessD mailing list