473,396 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to use items in a list as a hyperlink

sam
Hi all,

Kindly have a look to the code given below
************************************************** ***************************
Public Function CountFiles(strDir As String, Optional SubDir As
Boolean) As Long

With Application.FileSearch
.NewSearch
.LookIn = strDir
.FileName = "*.*"
.SearchSubFolders = SubDir
If .Execute 0 Then
CountFiles = .FoundFiles.count
End If

For i = 1 To .FoundFiles.count
Me.list1.AddItem (.FoundFiles(i))
Next i

End With
End Function
************************************************** **********************
you must have understood that this code is helping me to count the
number of files in a given folder and adding the names of those files
in a listbox.
It is adding the file name in the list box as
"I:\folder1\subfolder1\file1.doc"
but i want the name to be added in the list box as "file1.doc"

My second question is , is it possible to open the same file in the
list box by double clicking the filename.

can any one give me the solution for the problem.

sam

Dec 19 '06 #1
4 1763
On 19 Dec 2006 03:54:34 -0800, "sam" <sa****************@gmail.com>
wrote:

I think the FileSearch object is a bit limited. Here is similar code
using the more powerful FileSystemObject:

Private Function fsoCountFiles(ByVal strDir As String)
Dim fso As Scripting.FileSystemObject
Dim folder As Scripting.folder
Dim file As Scripting.file

Set fso = New Scripting.FileSystemObject
Set folder = fso.GetFolder(strDir)
For Each file In folder.Files
Me.List4.AddItem (file.Name)
Next file
Set file = Nothing
Set folder = Nothing
Set fso = Nothing
End Function

Then the double-click event:
Private Sub List4_DblClick(Cancel As Integer)
Dim strFullName As String
'Text0 has the root for the search.
strFullName = Me.Text0.Value & "\" &
List4.ItemData(List4.ListIndex)
Application.FollowHyperlink strFullName
End Sub

-Tom.
>Hi all,

Kindly have a look to the code given below
************************************************* ****************************
Public Function CountFiles(strDir As String, Optional SubDir As
Boolean) As Long

With Application.FileSearch
.NewSearch
.LookIn = strDir
.FileName = "*.*"
.SearchSubFolders = SubDir
If .Execute 0 Then
CountFiles = .FoundFiles.count
End If

For i = 1 To .FoundFiles.count
Me.list1.AddItem (.FoundFiles(i))
Next i

End With
End Function
************************************************* ***********************
you must have understood that this code is helping me to count the
number of files in a given folder and adding the names of those files
in a listbox.
It is adding the file name in the list box as
"I:\folder1\subfolder1\file1.doc"
but i want the name to be added in the list box as "file1.doc"

My second question is , is it possible to open the same file in the
list box by double clicking the filename.

can any one give me the solution for the problem.

sam
Dec 19 '06 #2
sam
Thanks tom

when i am running your code it is giving me compile error on this line

List4.ItemData(List4.ListIndex)

for ItemData it says "invalid use of property"

is it because my list box is unbound
the values that are in the list are not bound to any field in the table
these values are just the name of the files in a particular folder
i just want to open these files on double click

is there any solution to this problem

sam
Tom van Stiphout wrote:
On 19 Dec 2006 03:54:34 -0800, "sam" <sa****************@gmail.com>
wrote:

I think the FileSearch object is a bit limited. Here is similar code
using the more powerful FileSystemObject:

Private Function fsoCountFiles(ByVal strDir As String)
Dim fso As Scripting.FileSystemObject
Dim folder As Scripting.folder
Dim file As Scripting.file

Set fso = New Scripting.FileSystemObject
Set folder = fso.GetFolder(strDir)
For Each file In folder.Files
Me.List4.AddItem (file.Name)
Next file
Set file = Nothing
Set folder = Nothing
Set fso = Nothing
End Function

Then the double-click event:
Private Sub List4_DblClick(Cancel As Integer)
Dim strFullName As String
'Text0 has the root for the search.
strFullName = Me.Text0.Value & "\" &
List4.ItemData(List4.ListIndex)
Application.FollowHyperlink strFullName
End Sub

-Tom.
Hi all,

Kindly have a look to the code given below
************************************************** ***************************
Public Function CountFiles(strDir As String, Optional SubDir As
Boolean) As Long

With Application.FileSearch
.NewSearch
.LookIn = strDir
.FileName = "*.*"
.SearchSubFolders = SubDir
If .Execute 0 Then
CountFiles = .FoundFiles.count
End If

For i = 1 To .FoundFiles.count
Me.list1.AddItem (.FoundFiles(i))
Next i

End With
End Function
************************************************** **********************
you must have understood that this code is helping me to count the
number of files in a given folder and adding the names of those files
in a listbox.
It is adding the file name in the list box as
"I:\folder1\subfolder1\file1.doc"
but i want the name to be added in the list box as "file1.doc"

My second question is , is it possible to open the same file in the
list box by double clicking the filename.

can any one give me the solution for the problem.

sam
Dec 20 '06 #3
On 20 Dec 2006 04:23:36 -0800, "sam" <sa****************@gmail.com>
wrote:

Mine was unbound as well. I was using Access 2003. You?
-Tom.

>Thanks tom

when i am running your code it is giving me compile error on this line

List4.ItemData(List4.ListIndex)

for ItemData it says "invalid use of property"

is it because my list box is unbound
the values that are in the list are not bound to any field in the table
these values are just the name of the files in a particular folder
i just want to open these files on double click

is there any solution to this problem

sam
Tom van Stiphout wrote:
>On 19 Dec 2006 03:54:34 -0800, "sam" <sa****************@gmail.com>
wrote:

I think the FileSearch object is a bit limited. Here is similar code
using the more powerful FileSystemObject:

Private Function fsoCountFiles(ByVal strDir As String)
Dim fso As Scripting.FileSystemObject
Dim folder As Scripting.folder
Dim file As Scripting.file

Set fso = New Scripting.FileSystemObject
Set folder = fso.GetFolder(strDir)
For Each file In folder.Files
Me.List4.AddItem (file.Name)
Next file
Set file = Nothing
Set folder = Nothing
Set fso = Nothing
End Function

Then the double-click event:
Private Sub List4_DblClick(Cancel As Integer)
Dim strFullName As String
'Text0 has the root for the search.
strFullName = Me.Text0.Value & "\" &
List4.ItemData(List4.ListIndex)
Application.FollowHyperlink strFullName
End Sub

-Tom.
>Hi all,

Kindly have a look to the code given below
************************************************* ****************************
Public Function CountFiles(strDir As String, Optional SubDir As
Boolean) As Long

With Application.FileSearch
.NewSearch
.LookIn = strDir
.FileName = "*.*"
.SearchSubFolders = SubDir
If .Execute 0 Then
CountFiles = .FoundFiles.count
End If

For i = 1 To .FoundFiles.count
Me.list1.AddItem (.FoundFiles(i))
Next i

End With
End Function
************************************************* ***********************
you must have understood that this code is helping me to count the
number of files in a given folder and adding the names of those files
in a listbox.
It is adding the file name in the list box as
"I:\folder1\subfolder1\file1.doc"
but i want the name to be added in the list box as "file1.doc"

My second question is , is it possible to open the same file in the
list box by double clicking the filename.

can any one give me the solution for the problem.

sam
Dec 20 '06 #4
sam
i am also using access 2003
i will just check may be i am making another mistake
reply you tomorrow

Tom van Stiphout wrote:
On 20 Dec 2006 04:23:36 -0800, "sam" <sa****************@gmail.com>
wrote:

Mine was unbound as well. I was using Access 2003. You?
-Tom.

Thanks tom

when i am running your code it is giving me compile error on this line

List4.ItemData(List4.ListIndex)

for ItemData it says "invalid use of property"

is it because my list box is unbound
the values that are in the list are not bound to any field in the table
these values are just the name of the files in a particular folder
i just want to open these files on double click

is there any solution to this problem

sam
Tom van Stiphout wrote:
On 19 Dec 2006 03:54:34 -0800, "sam" <sa****************@gmail.com>
wrote:

I think the FileSearch object is a bit limited. Here is similar code
using the more powerful FileSystemObject:

Private Function fsoCountFiles(ByVal strDir As String)
Dim fso As Scripting.FileSystemObject
Dim folder As Scripting.folder
Dim file As Scripting.file

Set fso = New Scripting.FileSystemObject
Set folder = fso.GetFolder(strDir)
For Each file In folder.Files
Me.List4.AddItem (file.Name)
Next file
Set file = Nothing
Set folder = Nothing
Set fso = Nothing
End Function

Then the double-click event:
Private Sub List4_DblClick(Cancel As Integer)
Dim strFullName As String
'Text0 has the root for the search.
strFullName = Me.Text0.Value & "\" &
List4.ItemData(List4.ListIndex)
Application.FollowHyperlink strFullName
End Sub

-Tom.

Hi all,

Kindly have a look to the code given below
************************************************** ***************************
Public Function CountFiles(strDir As String, Optional SubDir As
Boolean) As Long

With Application.FileSearch
.NewSearch
.LookIn = strDir
.FileName = "*.*"
.SearchSubFolders = SubDir
If .Execute 0 Then
CountFiles = .FoundFiles.count
End If

For i = 1 To .FoundFiles.count
Me.list1.AddItem (.FoundFiles(i))
Next i

End With
End Function
************************************************** **********************
you must have understood that this code is helping me to count the
number of files in a given folder and adding the names of those files
in a listbox.
It is adding the file name in the list box as
"I:\folder1\subfolder1\file1.doc"
but i want the name to be added in the list box as "file1.doc"

My second question is , is it possible to open the same file in the
list box by double clicking the filename.

can any one give me the solution for the problem.

sam
Dec 20 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: tabonni | last post by:
My situation is: I got two ASP pages. One is ASP email form (I'm using Persist ASP Email component). Another one has all file links in it. For example, when user click Outlook course hyperlink....
3
by: tabonni | last post by:
My situation is: I got two ASP pages. One is ASP email form (I'm using Persist ASP Email component). Another one has all file links in it. For example, when user click Outlook course hyperlink....
5
by: Tom | last post by:
Hi, I created a table with a field to store the full path of the uploading images The table scheme is i path //path to the uploading imag userid //who upload i Now, I want to display...
0
by: Nick | last post by:
Hi, I have a Repeater control and want to bind a hyperlink to each repeated row. For this I can use the following syntax (excuse any incorrect naming but I don't have any code to hand): ...
1
by: diatom | last post by:
Hello, I have the items of a table bound to a DataGrid control on my web form. How would I go about letting the user click on an item in the DataGrid control to download the content. For...
8
by: fiefie.niles | last post by:
I am new to ASP.Net. I use VB.NET as the language and Visual Studio ..NET 2003. On my WebForm I have a label called "Categories". I would like to read all the categories from the database and...
1
by: sanju | last post by:
Hi , I am displaying 5 photos of a user(getting image path from database) and binding them to hyperlink control and adding that Hyperlink control to Datalist container in code behind file. ...
1
by: obs | last post by:
Hi. I'm using the following code to change a hyperlink attributes of a hyperlink which is located in an itemtemplate of a datalist. When I debug it the attributes are changed and everything is...
7
by: Clamato | last post by:
Hello everyone, I've been working on this for a bit and wonder if anyone can shed some light on my situation. My ultimate goal is to have a user select an item in a list box, have one column in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.