I need to use late binding in a project because it's company standard
to not include references which aren't MS defaults, so I can't add the
scripting runtime.
I need to be able to search folders (and sub-forders) for a file name,
and then copy the file to a specified directory (at the moment it's
C:\TempCD but that will change later.
All I have so far is the following, I believe my main issue to tackle
is to figure out how to get to sub-folders:
Private Function CheckFile(strPa th As String)
Dim FrmScreen As Form_ScrMainScr eens
Dim X As Integer
DoCmd.Hourglass True
Set FrmScreen = Scr(mvFormId)
Dim db As Database
Dim rec As dao.Recordset
Dim ICN_Name As String
Dim G, Y, z As Variant
Dim cnn As New ADODB.Connectio n
Dim rst As New ADODB.Recordset
Set cnn = CodeProject.Con nection
If Len(strPath) < 3 Then
strPath =
"\\Cca-audit\dfs-dc-01\Imaging\Clie nt\Out\CMS\Medi calRecords\"
End If
Dim filFile As Object, fdrFolder As Object, fdrSubFolder As Object
Dim fsoSysObj As Object, FL As Object, FLS As Object
Set fsoSysObj = CreateObject("S cripting.FileSy stemObject")
Set z = fsoSysObj.Drive s("Y")
Set fdrFolder = z.RootFolder
If fsoSysObj.Folde rExists(strPath ) Then
MsgBox "Im here"
Else
MsgBox "Failed"
End If
Set G = fsoSysObj.GetFo lder(strPath).F iles
For Each FL In G
Debug.Print (FL.Path)
Next FL
'THIS IS WHERE IT DIES
Set Y = G.getSubFolders
For Each FL In Y
Debug.Print (FL.Name)
Next FL
Set fdrFolder = fsoSysObj.GetFo lder(strPath).s ubfolder
Set fdrFolder = CreateObject("S cripting.Folder ")
Set fdrSubFolder = CreateObject("S cripting.Folder ")
Set filFile = CreateObject("S cripting.File")
If Len(strPath) < 3 Then
strPath =
"\\Cca-audit\dfs-dc-01\Imaging\Clie nt\Out\CMS\Medi calRecords\"
End If
For G = 0 To X - 1
ICN_Name = CmboMulti.List( G)
'************** *************** *************** *********
'************** *************** *************** *********
' This procedure returns all the files in a directory into
' a Dictionary object. If called recursively, it also returns
' all files in subfolders.
' Loop through Files collection
For Each filFile In fdrFolder.Files
If filFile.Name = ICN_Name & ".pdf" Then
fsoSysObj.copyf ile filFile.Path, "C:\TempCD\ "
End If
Next filFile
For Each fdrSubFolder In fdrFolder.SubFo lders
Y = CheckFile2(fdrS ubFolder.Path, ICN_Name)
If Y = True Then
GoTo FDRSRCH
End If
Next fdrSubFolder
'************** *************** *************** *********
FDRSRCH:
Next G
MsgBox "Medical Request Forms have been copied to C:\TempCD\"
For G = 0 To X - 1
DoCmd.SetWarnin gs True
MsgBox "Right-Click on the report body and print to PDF. Remember to
include 'CC' after the ICN # to differentiate between the CC Sheet and
Medical Request Forms."
DoCmd.OpenRepor t "rptAdmin_CcWor ksheet", acViewPreview, , "Icn = '" &
CmboMulti.List( G) & "'", acDialog
Next G
cnn.Close
Set cnn = Nothing
DoCmd.Hourglass False
End Function
Private Function CheckFile2(strP ath As String, ICN_Name As String) As
Variant
Dim FrmScreen As Form_ScrMainScr eens
Dim X As Integer
DoCmd.Hourglass True
Set FrmScreen = Scr(mvFormId)
Dim db As Database
Dim rec As dao.Recordset
Dim G As Variant
Dim cnn As New ADODB.Connectio n
Dim rst As New ADODB.Recordset
Set cnn = CodeProject.Con nection
Set fsoSysObj = CreateObject("S cripting.FileSy stemObject")
Set fdrFolder = CreateObject("S cripting.Folder ")
Set fdrSubFolder = CreateObject("S cripting.Folder ")
Set filFile = CreateObject("S cripting.File")
If Len(strPath) < 3 Then
strPath =
"\\Cca-audit\dfs-dc-01\Imaging\Clie nt\Out\CMS\Medi calRecords\"
End If
For Each filFile In fdrFolder.Files
If filFile.Name = ICN_Name & ".pdf" Then
fsoSysObj.copyf ile filFile.Path, "C:\TempCD\ "
CheckFile2 = "True"
GoTo FDRSRCH
End If
Next filFile
For Each fdrSubFolder In fdrFolder.SubFo lders
Call CheckFile2(fdrS ubFolder.Path, ICN_Name)
Next fdrSubFolder
FDRSRCH:
End Function 21 3065
There is a function demonstrating how to list files recursively (without
using any external references) here: http://allenbrowne.com/ser-59.html
It behaves a little differently than the scripting does, as it identifies
zip files as files instead of failing to list them or listing their
contents.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"ManningFan " <ma********@gma il.comwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
>I need to use late binding in a project because it's company standard
to not include references which aren't MS defaults, so I can't add the
scripting runtime.
I need to be able to search folders (and sub-forders) for a file name,
and then copy the file to a specified directory (at the moment it's
C:\TempCD but that will change later.
All I have so far is the following, I believe my main issue to tackle
is to figure out how to get to sub-folders:
Private Function CheckFile(strPa th As String)
Dim FrmScreen As Form_ScrMainScr eens
Dim X As Integer
DoCmd.Hourglass True
Set FrmScreen = Scr(mvFormId)
Dim db As Database
Dim rec As dao.Recordset
Dim ICN_Name As String
Dim G, Y, z As Variant
Dim cnn As New ADODB.Connectio n
Dim rst As New ADODB.Recordset
Set cnn = CodeProject.Con nection
If Len(strPath) < 3 Then
strPath =
"\\Cca-audit\dfs-dc-01\Imaging\Clie nt\Out\CMS\Medi calRecords\"
End If
Dim filFile As Object, fdrFolder As Object, fdrSubFolder As Object
Dim fsoSysObj As Object, FL As Object, FLS As Object
Set fsoSysObj = CreateObject("S cripting.FileSy stemObject")
Set z = fsoSysObj.Drive s("Y")
Set fdrFolder = z.RootFolder
If fsoSysObj.Folde rExists(strPath ) Then
MsgBox "Im here"
Else
MsgBox "Failed"
End If
Set G = fsoSysObj.GetFo lder(strPath).F iles
For Each FL In G
Debug.Print (FL.Path)
Next FL
'THIS IS WHERE IT DIES
Set Y = G.getSubFolders
For Each FL In Y
Debug.Print (FL.Name)
Next FL
Set fdrFolder = fsoSysObj.GetFo lder(strPath).s ubfolder
Set fdrFolder = CreateObject("S cripting.Folder ")
Set fdrSubFolder = CreateObject("S cripting.Folder ")
Set filFile = CreateObject("S cripting.File")
If Len(strPath) < 3 Then
strPath =
"\\Cca-audit\dfs-dc-01\Imaging\Clie nt\Out\CMS\Medi calRecords\"
End If
For G = 0 To X - 1
ICN_Name = CmboMulti.List( G)
'************** *************** *************** *********
'************** *************** *************** *********
' This procedure returns all the files in a directory into
' a Dictionary object. If called recursively, it also returns
' all files in subfolders.
' Loop through Files collection
For Each filFile In fdrFolder.Files
If filFile.Name = ICN_Name & ".pdf" Then
fsoSysObj.copyf ile filFile.Path, "C:\TempCD\ "
End If
Next filFile
For Each fdrSubFolder In fdrFolder.SubFo lders
Y = CheckFile2(fdrS ubFolder.Path, ICN_Name)
If Y = True Then
GoTo FDRSRCH
End If
Next fdrSubFolder
'************** *************** *************** *********
FDRSRCH:
Next G
MsgBox "Medical Request Forms have been copied to C:\TempCD\"
For G = 0 To X - 1
DoCmd.SetWarnin gs True
MsgBox "Right-Click on the report body and print to PDF. Remember to
include 'CC' after the ICN # to differentiate between the CC Sheet and
Medical Request Forms."
DoCmd.OpenRepor t "rptAdmin_CcWor ksheet", acViewPreview, , "Icn = '" &
CmboMulti.List( G) & "'", acDialog
Next G
cnn.Close
Set cnn = Nothing
DoCmd.Hourglass False
End Function
Private Function CheckFile2(strP ath As String, ICN_Name As String) As
Variant
Dim FrmScreen As Form_ScrMainScr eens
Dim X As Integer
DoCmd.Hourglass True
Set FrmScreen = Scr(mvFormId)
Dim db As Database
Dim rec As dao.Recordset
Dim G As Variant
Dim cnn As New ADODB.Connectio n
Dim rst As New ADODB.Recordset
Set cnn = CodeProject.Con nection
Set fsoSysObj = CreateObject("S cripting.FileSy stemObject")
Set fdrFolder = CreateObject("S cripting.Folder ")
Set fdrSubFolder = CreateObject("S cripting.Folder ")
Set filFile = CreateObject("S cripting.File")
If Len(strPath) < 3 Then
strPath =
"\\Cca-audit\dfs-dc-01\Imaging\Clie nt\Out\CMS\Medi calRecords\"
End If
For Each filFile In fdrFolder.Files
If filFile.Name = ICN_Name & ".pdf" Then
fsoSysObj.copyf ile filFile.Path, "C:\TempCD\ "
CheckFile2 = "True"
GoTo FDRSRCH
End If
Next filFile
For Each fdrSubFolder In fdrFolder.SubFo lders
Call CheckFile2(fdrS ubFolder.Path, ICN_Name)
Next fdrSubFolder
FDRSRCH:
End Function
"Allen Browne" <Al*********@Se eSig.Invalidwro te in
news:44******** *************** @per-qv1-newsreader-01.iinet.net.au :
There is a function demonstrating how to list files recursively
(without using any external references) here: http://allenbrowne.com/ser-59.html
It behaves a little differently than the scripting does, as it
identifies zip files as files instead of failing to list them or
listing their contents.
That nice reference aside, can the FSO simply not be used with late
binding?
--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Yes, probably it's main place of use is in scripting where you don't have
any other choice.
--
Terry Kreft
"David W. Fenton" <XX*******@dfen ton.com.invalid wrote in message
news:Xn******** *************** ***********@127 .0.0.1...
"Allen Browne" <Al*********@Se eSig.Invalidwro te in
news:44******** *************** @per-qv1-newsreader-01.iinet.net.au :
There is a function demonstrating how to list files recursively
(without using any external references) here: http://allenbrowne.com/ser-59.html
It behaves a little differently than the scripting does, as it
identifies zip files as files instead of failing to list them or
listing their contents.
That nice reference aside, can the FSO simply not be used with late
binding?
--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
"David W. Fenton" <XX*******@dfen ton.com.invalid wrote in message
<Xn************ *************** *******@127.0.0 .1>:
"Allen Browne" <Al*********@Se eSig.Invalidwro te in
news:44******** *************** @per-qv1-newsreader-01.iinet.net.au :
>There is a function demonstrating how to list files recursively (without using any external references) here: http://allenbrowne.com/ser-59.html
It behaves a little differently than the scripting does, as it identifies zip files as files instead of failing to list them or listing their contents.
That nice reference aside, can the FSO simply not be used with late
binding?
One can use late binding with all of the scripting objects. I should
think the below should work, as long as scripting is enabled on your
setup.
Public Function SearchFiles(ByR ef fldr As Object)
Dim fl As Object
Dim f As Object
Debug.Print fldr.Path
For Each f In fldr.Files
Debug.Print , f.Name
Next f
For Each fl In fldr.SubFolders
SearchFiles fl
Next fl
End Function
Sub SearchAllFiles( )
Dim fso As Object
Dim strPath As String
strPath = "c:" ' or narrow it down a bit ;-)
Set fso = CreateObject("s cripting.filesy stemobject")
SearchFiles fso.GetFolder(s trPath)
End Sub
--
Roy-Vidar
RoyVidar <ro************ *@yahoo.nowrote in
news:mn******** *************** @yahoo.no:
One can use late binding with all of the scripting objects. I
should think the below should work, as long as scripting is
enabled on your setup.
Why was the original poster having the problem, then? Was it an
error that would have occurred with early binding as well?
--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
"David W. Fenton" <XX*******@dfen ton.com.invalid wrote in message
<Xn************ *************** *******@127.0.0 .1>:
RoyVidar <ro************ *@yahoo.nowrote in
news:mn******** *************** @yahoo.no:
>One can use late binding with all of the scripting objects. I should think the below should work, as long as scripting is enabled on your setup.
Why was the original poster having the problem, then? Was it an
error that would have occurred with early binding as well?
That's hard for me to say, but I think I'll guess that the error
might stem from the OP being unfamiliar with these objects.
The hint for the OP, is probably to develop using early binding,
and switch to late binding closer to deployment, if they still
intend to use this library.
Then I think they would have found there's no getSubFolders
property, but there's a SubFolders property of a folder object,
returning a collection of the subfolders of that folder.
--
Roy-Vidar
On 20 Jul 2006 10:45:16 -0700, "ManningFan " <ma********@gma il.comwrote:
>I need to use late binding in a project because it's company standard to not include references which aren't MS defaults, so I can't add the scripting runtime.
I suppose the company policy relates to avoiding version dependency, but scripting is something many
admins turn off so late binding could produce a nasty surprise further down the line.
I would follow Allen's suggestion.
jim blunt <do**@ask.comwr ote in
news:l7******** *************** *********@4ax.c om:
On 20 Jul 2006 10:45:16 -0700, "ManningFan " <ma********@gma il.com>
wrote:
>>I need to use late binding in a project because it's company standard to not include references which aren't MS defaults, so I can't add the scripting runtime.
I suppose the company policy relates to avoiding version
dependency, but scripting is something many admins turn off so
late binding could produce a nasty surprise further down the line.
I would follow Allen's suggestion.
Is there some fashion in which that error would not be trappable?
That is, if the scripting runtime is not installed, then the effort
to instantiate a scripting object should fail with a trappable error
number. One would need only to find out what it is and then handle
the error. For that matter, as long as you have error handling in
your procedure that instantiates the object, you should be safe.
Might be a good idea to write a sub that does nothing but
instantiate the object, so you would know exactly what the error
applies to.
--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
On Fri, 21 Jul 2006 16:00:13 -0500, "David W. Fenton" <XX*******@dfen ton.com.invalid wrote:
>jim blunt <do**@ask.comwr ote in news:l7******* *************** **********@4ax. com:
>On 20 Jul 2006 10:45:16 -0700, "ManningFan " <ma********@gma il.com> wrote:
>>>I need to use late binding in a project because it's company standard to not include references which aren't MS defaults, so I can't add the scripting runtime.
I suppose the company policy relates to avoiding version dependency, but scripting is something many admins turn off so late binding could produce a nasty surprise further down the line. I would follow Allen's suggestion.
Is there some fashion in which that error would not be trappable? That is, if the scripting runtime is not installed, then the effort to instantiate a scripting object should fail with a trappable error number. One would need only to find out what it is and then handle the error. For that matter, as long as you have error handling in your procedure that instantiates the object, you should be safe. Might be a good idea to write a sub that does nothing but instantiate the object, so you would know exactly what the error applies to.
But even if you trapped the error how would you use the program if you are not allowed to use
scripting? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: 3A Web Hosting |
last post by:
Hi Folks
This is probably starring me in the face but how do I read the contents
of a hard drive directory? I've been playing around with the
opendir($dir) sample from php.net and can read from the server without
problem but how can I read a list of files from the hard drive of the PC
(win98 (spit!)) I'm using? Basically what I want to do...
|
by: Nate |
last post by:
Hello,
I am trying to recover a SQL Server 7 database from another hard disk
drive that has a corrupted Windows 2000 Advanced Server installation. I
am not able to repair the corrupted Windows 2000 Advanced Server
installation but the file system is intact. I have installed a new copy
of SQL Server 7 onto a new hard disk and have used the...
|
by: Daniel |
last post by:
when writing out a file from .net, when is the file created? after the bytes
are all written to the hard drive or before the bytes are written to the
hard drive?
|
by: Ron Johnson |
last post by:
http://hardware.devchannel.org/hardwarechannel/03/10/20/1953249.shtml?tid=20&tid=38&tid=49
--
-----------------------------------------------------------------
Ron Johnson, Jr. ron.l.johnson@cox.net
Jefferson, LA USA
I can't make you have an abortion, but you can *make* me pay
child support for 18 years? However, if I want the child (and...
|
by: Xah Lee |
last post by:
The Harm of hard-wrapping Lines
20050222
Computing Folks of the industry:
please spread the debunking of the truncating line business of the
fucking unix-loving fuckheads, as outlines here:
http://xahlee.org/UnixResource_dir/writ/truncate_line.html
| |
by: ward |
last post by:
Good morning.
I created an edit_task page that allows the user to edit tasks for the
database. I entered some text and used some hard returns.
Put when I went to view the tasks (using a PHP script if it matters),
the hard returns didn't "take." None of em. All of the text is
jumbled together.
Well I checked within the MySQL database...
|
by: Otie |
last post by:
Hi,
Is there a way for VB5 to determine exactly where on a hard drive a .exe
file is stored upon the .exe file's first copying to the hard drive? What I
need to know is the exact hard drive sector, cluster, partition, etc.
information so I can use it later on to determine if the file was ever
deleted and restored or moved elsewhere.
...
|
by: =?Utf-8?B?R2VvcmR5?= |
last post by:
Hello everyone, I would really appreciate if someone helped me in this matter
cause I am going to lose my mind...
I am using a Sony Vaio Laptop with Windows XP professional (512MB Ram, 1,7
GHz CPU clock, 50GB Hard disk) and for the past 10 days i have noticed that
my hard disk space is decreasing dramatically without installing or running
any...
|
by: Kurt Mueller |
last post by:
David,
Am 07.10.2008 um 01:25 schrieb Blubaugh, David A.:
As others mentioned before, python is not the right tool for "HARD
REAL TIME".
But: Maybe you can isolate the part of your application that needs
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |