使用FileDialog属性打开并在文本框中显示FileName [英] Using FileDialog property to open and display FileName in a textbox
问题描述
嗨好朋友,
我想知道如何在文本框中显示所选文件的FileName,并使用FileDialog属性打开它。我从库中导入了必要的引用 - Microsoft Office Object Library 10.0。 Tks
控制:
TextBox - 显示FileName
按钮 - 打开
代码:
VBA:
< blockquote>
嗨好朋友,
我想知道如何在文本框中显示所选文件的FileName并使用它打开FileDialog属性。我从库中导入了必要的引用 - Microsoft Office Object Library 10.0。 Tks
控制:
TextBox - 显示FileName
按钮 - 打开
代码:
VBA:
Private Sub Command_Onclick()
Dim fd As FileDialog
Dim varSelected As Variant
设置fd = Application.FileDialog(msopen ....)
用fd
.MultiSelect = True
。显示
如果。 show = -1然后
For Each varSelected .SelectedItem
下一页
Else
MsgBox" ;取消]
结束如果
结束
结束子
< b>以下代码将显示使用FileDialog对象在名为txtDisplayFileNames的文本框中选择的多个文件的列表:
tks用于提示回复。但是,执行prog时无法打开所选文件。它只显示文本框中所选文件的名称。我还需要从DirList中打开所选文件。我可以知道如何实现这一目标?
编程的逻辑: -
编程应该以这样的方式运行,其中所选文件的名称显示在文本框中以及执行时打开。 Tks
以下代码将显示使用FileDialog对象在名为txtDisplayFileNames的文本框中选择的多个文件的列表: / b>
展开 | 选择 | Wrap | 行号
tks提示答复。但是,执行prog时无法打开所选文件。它只显示文本框中所选文件的名称。我还需要从DirList中打开所选文件。我可以知道如何实现这一目标?
编程的逻辑: -
编程应该以这样的方式运行,其中所选文件的名称显示在文本框中以及执行时打开。 Tks
- 您是否尝试打开单个或多个文件?
- 您希望使用哪些文件类型扩展名?仅限于? (要打开哪些文件类型)?
- 您确定要设置MultiSelect = True。
- 您到底想要完成什么?
Hi pals,
I would like to know how to display the FileName of the selected file in the textbox and open it using FileDialog property. I have imported the necessary reference from the library - Microsoft Office Object Library 10.0. Tks
Control:
TextBox - Display FileName
Button - Open
Code:
VBA:
Expand|Select|Wrap|Line Numbers解决方案Hi pals,
I would like to know how to display the FileName of the selected file in the textbox and open it using FileDialog property. I have imported the necessary reference from the library - Microsoft Office Object Library 10.0. Tks
Control:
TextBox - Display FileName
Button - Open
Code:
VBA:
Private Sub Command_Onclick()
Dim fd As FileDialog
Dim varSelected As Variant
Set fd = Application.FileDialog(msopen....)
With fd
.MultiSelect = True
.Show
If . show = -1 Then
For Each varSelected .SelectedItem
Next
Else
MsgBox "Cancel"
End If
End With
End SubThe following code will display a listing of multiple Files selected in a Text Box named txtDisplayFileNames using the FileDialog Object:
Expand|Select|Wrap|Line Numbers
tks for the prompt reply. However, the selected file cannot be opened when the prog is executed. It just display the name of the selected file in the textbox. What I need further is to open the selected file from the DirList. May I know how can that be achieved?
Logic of the prog:-
The prog should run in such a way, whereby the name of the selected file is displayed in the textbox as well as open upon execution. Tks
The following code will display a listing of multiple Files selected in a Text Box named txtDisplayFileNames using the FileDialog Object:
Expand|Select|Wrap|Line Numbers
tks for the prompt reply. However, the selected file cannot be opened when the prog is executed. It just display the name of the selected file in the textbox. What I need further is to open the selected file from the DirList. May I know how can that be achieved?
Logic of the prog:-
The prog should run in such a way, whereby the name of the selected file is displayed in the textbox as well as open upon execution. Tks
- Are you trying to Open Single or Multiple Files?
- What File Type Extensions do you wish to be limited to? (What File Types are to opened)?
- Are you sure you want to set MultiSelect = True.
- What exactly are you trying to accomplish?
这篇关于使用FileDialog属性打开并在文本框中显示FileName的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文登录 关闭
扫码关注1秒登录发送“验证码”获取 | 15天全站免登陆