dim
s
as
string,
t
as
integer
private
sub
dir1_change()
if
ubound(split(dir1.path,
"\"))
<扒伏
t
then
dir1.path
=
s
end
sub
private
sub
form_load()
dir1.path
=
app.path
'设置指定 *** 作文件夹,这里是程序所在目录
s
=
dir1.path
t
=
ubound(split(s,
"\"))
end
sub
补充回答:
这个似乎就和你一开始的要求有冲突了。如果这个文件夹是指定文件夹的子文件夹,那么你可以通过dirlistbox随意 *** 作,如果不是,那么根据你的要求,就不能随意打开。如果你的意思是指任意设置指定的目录,那么我在上面的程序中也有说明了,只要给dir1.path赋值即可(比如dir1.path
=
"d:\crt"),方法有多种(包括读取文件中保存的路径名等),但不管用什么方法,都不能够在程序界面上给用户任意选春码携择,否则你开始的那些模伍要求就没意义了。
‘...按钮的click事件毕物型写蚂肆代码'这是一个打开ini文件的例子,要打开其他类型文件修改函数即可手猜。
text1=fun_GetSaveFileName()
'*********************************************************************************************
'名称 fun_GetSaveFileName
'作者 Morn Woo 于 2005.4.5
'功能 接收用户指定的ini文件
'*********************************************************************************************
Function fun_GetOpenIniName()
fun_GetOpenIniName = ""
With commondialog控件
.Filter = "(*.ini)|*.ini"
.DefaultExt = ".ini"
.DialogTitle = "查找要打开的配置文件"
.InitDir = App.Path
.CancelError = False
.Flags = cdlOFNOverwritePrompt + cdlOFNPathMustExist
.Action = 1'打开对话框
If IsNull(.FileName) Then Exit Function
If Trim(.FileName) = "" Then Exit Function
fun_GetOpenIniName = .FileName
End With
End Function
Dim a() As StringPrivate Sub Dir1_Change()
File1.Path = Dir1.Path
Label1.Caption = Dir1.Path
End Sub
Private Sub Drive1_Change()
On Error GoTo err1
Dir1.Path = Drive1.Drive
Exit Sub
err1:
MsgBox Err.Description, vbInformation + vbOKOnly, "提示"
End Sub
Private Sub Command1_Click()
Dim i As Integer, j As Integer
Dim ifieldcount As Integer, irecordcount As Integer
Dim wdapp As Word.Application
Dim wddoc As Word.Document
Dim atable As Word.Table
If Option2.Value = True Then
ReDim a(1 To File1.ListCount)
For i = 1 To File1.ListCount
b = File1.List(i)
a(i) = b
Next
End If
If Option1.Value = True Then
ReDim a(1 To Dir1.ListCount)
For i = 1 To Dir1.ListCount
b = Dir1.List(i)
a(i) = b
Next
End If
End Sub
这段程序 复制过去 就行了 创建的控件有 两个option 让你选择 要提取文件夹 还是文件歼好路径的 选中option 1 就是提取文件夹的 option2 就是提取文件的 然后再创建 Drive1 Dir1 File1 这三个亮改消 选择文件路径的 控件 再加一个 command 按钮 就行了 有疑问再联系我!!!!敬知!这个 只是 文件路径 你看看 是你想要的话 我再给你写 提取文件夹和文件名的代码!!!!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)