从Excel VBA中浏览文件

时间:2022-11-19 22:58:31

How can I put up a "File Open" dialog from some VBA running in Excel?

如何从Excel中运行的某个VBA中打开“文件打开”对话框?

I'm using Excel 2003.

我正在使用Excel 2003。

2 个解决方案

#1


9  

You want the Application.GetOpenFilename function. Copying from VBA Object Browser:

您需要Application.GetOpenFilename函数。从VBA对象浏览器复制:

Function GetOpenFilename([FileFilter], [FilterIndex], [Title], [ButtonText], [MultiSelect])
Member of Excel.Application

函数GetOpenFilename([FileFilter],[FilterIndex],[Title],[ButtonText],[MultiSelect])Excel.Application的成员

#2


2  

Add a reference to ComDLG32.OCX and then something like...

添加对ComDLG32.OCX的引用,然后添加...

Sub PromptForFile()
Dim d As New MSComDlg.CommonDialog

d.Filter = "xls"
d.Filename = "*.xls"
d.ShowOpen

Excel.Workbooks.Open d.Filename

Set d = Nothing
End Sub 

#1


9  

You want the Application.GetOpenFilename function. Copying from VBA Object Browser:

您需要Application.GetOpenFilename函数。从VBA对象浏览器复制:

Function GetOpenFilename([FileFilter], [FilterIndex], [Title], [ButtonText], [MultiSelect])
Member of Excel.Application

函数GetOpenFilename([FileFilter],[FilterIndex],[Title],[ButtonText],[MultiSelect])Excel.Application的成员

#2


2  

Add a reference to ComDLG32.OCX and then something like...

添加对ComDLG32.OCX的引用,然后添加...

Sub PromptForFile()
Dim d As New MSComDlg.CommonDialog

d.Filter = "xls"
d.Filename = "*.xls"
d.ShowOpen

Excel.Workbooks.Open d.Filename

Set d = Nothing
End Sub