Set oDLG = CreateObject("MSComDlg.CommonDialog")
With oDLG
.DialogTitle = "打开文件"
.FilterIndex = 1
'.flags = 512 '设置多选文件选项, 如不需要则删除此行
.MaxFileSize = 255
.ShowOpen '选择其他内容:.ShowPrinter,.ShowColor,ShowFont
'.Color=Screen.ActiveForm.ForeColor
'.ShowColor
If .FileName <> "" Then
OpenFileDlg = .FileName
msgbox OpenFileDlg,,"你选择的文件名是:"
i=instrrev(OpenFileDlg,"\")
if i>0 then OpenFileDlg=left(OpenFileDlg,i-1)
msgbox OpenFileDlg,,"你选择的文件夹是:"
End If
End With
Set oDLG = Nothing
Set objDialog=CreateObject("UserAccounts.CommonDialog")objDialog.Filter="*.*"
objDialog.InitialDir="C:\"
tfile=objDialog.ShowOpen
MsgBox objDialog.FileName
建议你还是换个方式吧,手工设置相对路径,看看下面的代码,或许对你有用dim s,dir0,dir1,dir2
s=wscript.scriptfullname
on error resume next
dir0=left(wscript.scriptfullname,instrrev(s,"\")-1)
dir1=left(wscript.scriptfullname,instrrev(dir0,"\")-1)
dir2=left(wscript.scriptfullname,instrrev(dir1,"\")-1)
msgbox dir0'当前目录
msgbox dir1'上层目录
msgbox dir2'上上层目录
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)