[AccessD] CmdRunApp Help

John W. Colby jcolby at colbyconsulting.com
Thu Dec 11 09:22:44 CST 2003


Erwin,

Below is an example of code (stripped down for clarity) that I use in one
project.  Obviously the path strings and such are module globals that you
would change to your needs.

Function ProcessAllClaimNumFiles()
On Error GoTo Err_ProcessAllClaimNumFiles
Dim fs As Scripting.FileSystemObject
Dim fldr As Scripting.Folder
Dim File As Scripting.File

    Set fs = New Scripting.FileSystemObject
    Set fldr = fs.GetFolder(strPathDISReports & strPathSTDXlsSubfolder)
    For Each File In fldr.Files
        fs.DeleteFile strPathDISReports & "TODAY_STD.xls", True
        File.Copy strPathDISReports & "TODAY_STD.xls", True
	.
	.
	.	other processing here
	.
    Next File
Exit_ProcessAllClaimNumFiles:
On Error Resume Next
    Set fldr = Nothing
    Set fs = Nothing
Exit Function
Err_ProcessAllClaimNumFiles:
    Select Case Err
    Case 0      '.insert Errors you wish to ignore here
        Resume Next
    Case 53     'file not found to be deleted
        Resume Next
    Case Else   '.All other errors will trap
        Beep
        MsgBox Err.Description, , "Error in Function
basPaymentImportingNew.ProcessAllClaimNumFiles"
        Resume Exit_ProcessAllClaimNumFiles
    End Select
    Resume 0    '.FOR TROUBLESHOOTING
End Function

John W. Colby
www.ColbyConsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Erwin Craps -
IT Helps
Sent: Thursday, December 11, 2003 10:07 AM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] CmdRunApp Help


I'm gonna check this file iteration thing, sounds much better than the
VBA routine I have now... Thx



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

Erwin,

Absolutely!

As for being a "better way", I really like the FSO.  On the other hand
there are MANY sysadmins out there that disable it (I think it is a
service or something).  It isn't safe to just assume it is going to
work, thus having code for "the alternative" (the built in VB commands)
is a necessity as well.  I have all that old stuff in my framework from
long ago before I used the FSO.

I too used GW-Basic back in the late 80s / early 90s to build a
calibration test stand for Puritan-Bennett (ventilators) to test air
flow sensors - Hot Wire Anemometers - where the air flowing past a
heated wire in a glass tube changed the temperature and thus the
resistance of the wire.  The current flow through the wire was measured
to determine how much air was moving through the tube.  Pretty scary to
think that gw-basic was used to test this stuff.

John W. Colby
www.ColbyConsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Erwin Craps -
IT Helps
Sent: Thursday, December 11, 2003 9:33 AM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] CmdRunApp Help


I understand that.
I appologise for this, but I interpreted your E-mail as a better way of
dooing things (which is true from what I understand now) then the VBA
functions.

My remark was not intentioned as an alternative solution but as a
question to you to know what is better about FSO cause I never used it
in Access (only in ASP).
This "nuance" most have been lost in the translation.
Again my appologies.
Hope you accept it.

Erwin

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

Nope, I use it because it has a programming model, with properties /
methods / child objects, complete with intellisense.

I do a ton of things like saving email attachments (from the Outlook
model) to specific directories, then using the filesystemobject to get a
directory and use the built-in iterator (for next) to iterate all files
in the directory importing payments, claim number updates and the likes
into a database.  Once I started doing that, I just wrote wrappers
around the code to dim the FSO and instantiate it, plus use a specific
command.  Having that code in place, I rarely use anything else unless
the FSO is specifically disabled on a specific client's net / machine.

I simply asked you to provide code because the gentleman originally
asked how to do this.  I provided an answer with code.  You provided a
"why not use the built-in vb commands".  I can find the built-in
commands should I ever need them, but the original gentleman obviously
needed help.  "Why not use the built-in VB commands" barely qualifies as
helpful.

;-)

John W. Colby
www.ColbyConsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Erwin Craps -
IT Helps
Sent: Thursday, December 11, 2003 2:21 AM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] CmdRunApp Help


Ah sorry John
I conclude with Gustav.
I learned these commands in GW-Basic/Quick Basic or something.

I just presumed you knew these commands and are using filesystemobject
for some specific reasons I'm not aware of.
Like speed, I sometimes have the impression that FileCopy is slower than
dooing a explorer copy.

Erwin

-----Oorspronkelijk bericht-----
Van: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] Namens Gustav Brock
Verzonden: woensdag 10 december 2003 14:23
Aan: Access Developers discussion and problem solving
Onderwerp: Re: [AccessD] CmdRunApp Help

Hi John

> Why not post code as I did?

Ahh John, it's too easy:

    FileCopy sourcefile, destfile
    Name destfile As johnsfile.txt

/gustav

> Why using the filesystemobject and not the regular VBA commands?
> Faster?

_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com





More information about the AccessD mailing list