窗口中有一个文本框和一个按钮,我想通过按钮在指定文件夹下找到和文本框内容一样的excel表,并给其给其指定单元格内赋值,请大师指教Dim txt As String = e.Form.Controls("TextBox1").Text
Dim web As WinForm.WebBrowser = e.Form.Controls("WebBrowser1")
For Each File As String In FileSys.GetFiles("l:\产品料单")
If file.EndsWith(".xls") = "txt.xls" Then
web.OfficeToolBar = True
web.Address = "txt.xls"
End If
Next
参考:http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&Id=149103
请大师再指导下如何按文本框内容找到文件夹下匹配的excel表
匹配的excel的文件名称?还是匹配excel里面某个单元格?
For Each File As String In FileSys.GetFiles("l:\产品料单")
If file.EndsWith(txt & ".xls") Then
web.OfficeToolBar = True
web.Address = File
exit for
End If
Next
增加一个自定义函数名称:abc,函数内容
dim dir as string = args(0)
dim txt as string = args(1)
For Each File As String In FileSys.GetFiles(dir ) If file.EndsWith(txt & ".xls") Then return File End If Next |
For Each dir2 As String In FileSys.GetDirectories(dir) 如果有子目录
dim s as string = Functions.Execute("abc",dir2 txt )
if s > "" then
retutn s
end if
Next
return ""
按钮
Dim txt As String = e.Form.Controls("TextBox1").Text
Dim web As WinForm.WebBrowser = e.Form.Controls("WebBrowser1")
dim file as string = Functions.Execute("abc","l:\产品料单",txt )
If file > "" Then
web.OfficeToolBar = True
web.Address = File
else
msgbox("没有找到")
End If