List a folders contents from a widows Directory

A

Allen Browne

You can pause the mouse over the variable while in break mode, or you can
open the Immediate Window (Ctrl+G) and ask:
? intCount

I will need to let you finish your debugging now, and move on to other
threads.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

K said:
Sorry Allen,

You must think I am new or something. I apreciate you taking the time to
guide me through this.

How do I ask Access for the Value of intCount

Allen Browne said:
Ask Access for the value of intCount.
It must be a number between 0 and the maximum number.
(That's what 'out of range' suggests is wrong.)

K said:
This line is Yellow with an arrow deside it

StrFiles(IntCount) = StrFileName

There is only one PDF file in the folder on the P Directory and the
Folder
is called "IT"

When I Debug the error and place my cursor over the yellow line it does
show
the correct PDF file which states : StrFileName = "the PDF File"

I have tried increasing the Static to 999 But I still get the same
error.

:

Which line gives the error?

Could there be more than 512 files in your folder? If so, increase the
511
in the static array definition at the top of the procedure.

Hi Allen,

Now I get this message

Run-time Error 9 - Subscript out of range.
Code looks like this:

Case 1 ' Open: load file names into
array
DirListBox = Timer
StrFileName = Dir$("P:\") ' Read filespec from a form
here???
Do While Len(StrFileName) > 0
StrFiles(IntCount) = StrFileName
StrFileName = Dir$("P:\it\*.pdf")

IntCount = IntCount + 1

:

Perhaps something like this:
StrFileName = Dir$("P:\MyFolder\*.pdf")

Hi Allen one last thing. The list shows all files in the
DIrectory
but
I
can
not seem to make it point to a specific folder and read the
contents
of
it.
Here is the code. Can you help me on that. P: is the drive.
Public
within
the
company. The folder I want it to show the files within is called
Flood.

Case 1 ' Open: load file names
into
array
DirListBox = Timer
StrFileName = Dir$("P:\") ' Read filespec from a
form
here???
Do While Len(StrFileName) > 0
StrFiles(IntCount) = StrFileName
StrFileName = Dir
IntCount = IntCount + 1

:

Hi Allen,

Thanks, Sorry I missed that comment.

I now get a run-time error 490 cannot open specified file.

Here is my code:
Private Sub List0_DblClick(Cancel As Integer)
If Not IsNull(Me.[List0]) Then
FollowHyperlink Me.[List0]
End If

End Sub
:

Go back to the 2nd reply I gave you, and pick up at step 5.
 
G

Guest

Okay it says 512
The static reads: Static StrFiles(0 To 511) As String however there is a
line stating
IntCount = IntCount + 1 which makes it 512. There is only one Pdf file in
the folder.



Allen Browne said:
You can pause the mouse over the variable while in break mode, or you can
open the Immediate Window (Ctrl+G) and ask:
? intCount

I will need to let you finish your debugging now, and move on to other
threads.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

K said:
Sorry Allen,

You must think I am new or something. I apreciate you taking the time to
guide me through this.

How do I ask Access for the Value of intCount

Allen Browne said:
Ask Access for the value of intCount.
It must be a number between 0 and the maximum number.
(That's what 'out of range' suggests is wrong.)

This line is Yellow with an arrow deside it

StrFiles(IntCount) = StrFileName

There is only one PDF file in the folder on the P Directory and the
Folder
is called "IT"

When I Debug the error and place my cursor over the yellow line it does
show
the correct PDF file which states : StrFileName = "the PDF File"

I have tried increasing the Static to 999 But I still get the same
error.

:

Which line gives the error?

Could there be more than 512 files in your folder? If so, increase the
511
in the static array definition at the top of the procedure.

Hi Allen,

Now I get this message

Run-time Error 9 - Subscript out of range.
Code looks like this:

Case 1 ' Open: load file names into
array
DirListBox = Timer
StrFileName = Dir$("P:\") ' Read filespec from a form
here???
Do While Len(StrFileName) > 0
StrFiles(IntCount) = StrFileName
StrFileName = Dir$("P:\it\*.pdf")

IntCount = IntCount + 1

:

Perhaps something like this:
StrFileName = Dir$("P:\MyFolder\*.pdf")

Hi Allen one last thing. The list shows all files in the
DIrectory
but
I
can
not seem to make it point to a specific folder and read the
contents
of
it.
Here is the code. Can you help me on that. P: is the drive.
Public
within
the
company. The folder I want it to show the files within is called
Flood.

Case 1 ' Open: load file names
into
array
DirListBox = Timer
StrFileName = Dir$("P:\") ' Read filespec from a
form
here???
Do While Len(StrFileName) > 0
StrFiles(IntCount) = StrFileName
StrFileName = Dir
IntCount = IntCount + 1

:

Hi Allen,

Thanks, Sorry I missed that comment.

I now get a run-time error 490 cannot open specified file.

Here is my code:
Private Sub List0_DblClick(Cancel As Integer)
If Not IsNull(Me.[List0]) Then
FollowHyperlink Me.[List0]
End If

End Sub
:

Go back to the 2nd reply I gave you, and pick up at step 5.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top