View file from Excel VBA

How can I open the "Open file" dialog from some VBA running in Excel?

I am using Excel 2003.

+3
source share
2 answers

You need a function Application.GetOpenFilename. Copy from VBA Object Browser:

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

+9
source

Add a link to ComDLG32.OCX, and then something like ...

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 
+2
source

Source: https://habr.com/ru/post/1698515/


All Articles