ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with UserForms (https://www.excelbanter.com/excel-programming/344043-help-userforms.html)

mb

Help with UserForms
 
Seem to have a problem with this line:

UserForm1.ListBox1.AddItem .FoundFiles(i)

Entire Script:

Sub FindFiles()
With Application.FileSearch
.NewSearch
.LookIn = "D:\AllData\APICS"
.SearchSubFolders = True
.TextorProperty = "APICS Dictionary"
.MatchTextExactly = True
.Filename = "*.xls"
.Execute
For i = 1 to .FoundFiles.Count
UserForm1.ListBox1.AddItem .FoundFiles(i)
next i
End With
UserForm1.Show
End Sub

Any ideas?

Thanks,
mb



Chip Pearson

Help with UserForms
 
Specifically what problem are you having with the line?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"mb" wrote in message
...
Seem to have a problem with this line:

UserForm1.ListBox1.AddItem .FoundFiles(i)

Entire Script:

Sub FindFiles()
With Application.FileSearch
.NewSearch
.LookIn = "D:\AllData\APICS"
.SearchSubFolders = True
.TextorProperty = "APICS Dictionary"
.MatchTextExactly = True
.Filename = "*.xls"
.Execute
For i = 1 to .FoundFiles.Count
UserForm1.ListBox1.AddItem .FoundFiles(i)
next i
End With
UserForm1.Show
End Sub

Any ideas?

Thanks,
mb





mb

Help with UserForms
 
Receiving a Run-time error '424': object required.


"Chip Pearson" wrote in message
...
Specifically what problem are you having with the line?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"mb" wrote in message
...
Seem to have a problem with this line:

UserForm1.ListBox1.AddItem .FoundFiles(i)

Entire Script:

Sub FindFiles()
With Application.FileSearch
.NewSearch
.LookIn = "D:\AllData\APICS"
.SearchSubFolders = True
.TextorProperty = "APICS Dictionary"
.MatchTextExactly = True
.Filename = "*.xls"
.Execute
For i = 1 to .FoundFiles.Count
UserForm1.ListBox1.AddItem .FoundFiles(i)
next i
End With
UserForm1.Show
End Sub

Any ideas?

Thanks,
mb







Leith Ross[_142_]

Help with UserForms
 

Hello MB,

You should check that the .FoundFiles.Count is not zero. If it is I
suspect .FoundFiles(i) object returns a Null. The .AddItem method will
fail if the item is not a string.

Try this...


Code:
--------------------
Sub FindFiles()

With Application.FileSearch
.NewSearch
.LookIn = "D:\AllData\APICS"
.SearchSubFolders = True
.TextorProperty = "APICS Dictionary"
.MatchTextExactly = True
.Filename = "*.xls"
.Execute
For i = 1 to .FoundFiles.Count
If .FoundFiles.Count = 0 Then Exit Sub
UserForm1.ListBox1.AddItem .FoundFiles(i)
Next i
End With

UserForm1.Show

End Sub

--------------------


Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=479954



All times are GMT +1. The time now is 06:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com