Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open File showing only Excel files
hey guys I want to be able to bring up an open file dialog
box that only looks for all microsoft excel type files. You know how when you click open it has that option for files of type. Thats the kind of thing I want to automatically happen. What is the code for this? I also have been using the Browse for folder code Chip Pearson gave me below: FName = BrowseFolder("Select a Workbook", "\\") If FName = "" Then GoTo SelectWorkbook Else 'ComboBox.Value = FName End If Private Const BIF_RETURNONLYFSDIRS As Long = &H1 Private Const BIF_DONTGOBELOWDOMAIN As Long = &H2 Private Const BIF_RETURNFSANCESTORS As Long = &H8 Private Const BIF_BROWSEFORCOMPUTER As Long = &H1000 Private Const BIF_BROWSEFORPRINTER As Long = &H2000 Private Const BIF_BROWSEINCLUDEFILES As Long = &H4000 Private Const MAX_PATH As Long = 260 Function BrowseFolder(Optional Caption As String, _ Optional InitialFolder As String) As String Dim SH As Shell32.Shell Dim F As Shell32.Folder Set SH = New Shell32.Shell Set F = SH.BrowseForFolder(0&, Caption, BIF_RETURNONLYFSDIRS, _ InitialFolder) If Not F Is Nothing Then BrowseFolder = F.Items.Item.path End If End Function Is there anyway with this code to show excel file types? Thank you Todd Huttenstine |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open File showing only Excel files
Todd,
The code you posted is for selecting a folder, not a file. You can't use that code to select a file. Instead, use GetOpenFilename. E.g., Dim FName As Variant FName = Application.GetOpenFilename("Excel Files (*.xls),*.xls)") If FName = False Then MsgBox "You didn't select a file" Else MsgBox "You selected: " & FName End If -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Todd Huttenstine" wrote in message ... hey guys I want to be able to bring up an open file dialog box that only looks for all microsoft excel type files. You know how when you click open it has that option for files of type. Thats the kind of thing I want to automatically happen. What is the code for this? I also have been using the Browse for folder code Chip Pearson gave me below: FName = BrowseFolder("Select a Workbook", "\\") If FName = "" Then GoTo SelectWorkbook Else 'ComboBox.Value = FName End If Private Const BIF_RETURNONLYFSDIRS As Long = &H1 Private Const BIF_DONTGOBELOWDOMAIN As Long = &H2 Private Const BIF_RETURNFSANCESTORS As Long = &H8 Private Const BIF_BROWSEFORCOMPUTER As Long = &H1000 Private Const BIF_BROWSEFORPRINTER As Long = &H2000 Private Const BIF_BROWSEINCLUDEFILES As Long = &H4000 Private Const MAX_PATH As Long = 260 Function BrowseFolder(Optional Caption As String, _ Optional InitialFolder As String) As String Dim SH As Shell32.Shell Dim F As Shell32.Folder Set SH = New Shell32.Shell Set F = SH.BrowseForFolder(0&, Caption, BIF_RETURNONLYFSDIRS, _ InitialFolder) If Not F Is Nothing Then BrowseFolder = F.Items.Item.path End If End Function Is there anyway with this code to show excel file types? Thank you Todd Huttenstine |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open File showing only Excel files
Hi Tod,
You could use : a = Application.GetOpenFilename Search iin help on GetOpenFilename, you can adjust to restrict only to xl files "Todd Huttenstine" wrote in message ... hey guys I want to be able to bring up an open file dialog box that only looks for all microsoft excel type files. You know how when you click open it has that option for files of type. Thats the kind of thing I want to automatically happen. What is the code for this? I also have been using the Browse for folder code Chip Pearson gave me below: FName = BrowseFolder("Select a Workbook", "\\") If FName = "" Then GoTo SelectWorkbook Else 'ComboBox.Value = FName End If Private Const BIF_RETURNONLYFSDIRS As Long = &H1 Private Const BIF_DONTGOBELOWDOMAIN As Long = &H2 Private Const BIF_RETURNFSANCESTORS As Long = &H8 Private Const BIF_BROWSEFORCOMPUTER As Long = &H1000 Private Const BIF_BROWSEFORPRINTER As Long = &H2000 Private Const BIF_BROWSEINCLUDEFILES As Long = &H4000 Private Const MAX_PATH As Long = 260 Function BrowseFolder(Optional Caption As String, _ Optional InitialFolder As String) As String Dim SH As Shell32.Shell Dim F As Shell32.Folder Set SH = New Shell32.Shell Set F = SH.BrowseForFolder(0&, Caption, BIF_RETURNONLYFSDIRS, _ InitialFolder) If Not F Is Nothing Then BrowseFolder = F.Items.Item.path End If End Function Is there anyway with this code to show excel file types? Thank you Todd Huttenstine |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
try to open excel files from explorer, 'file not found' | Excel Discussion (Misc queries) | |||
Excel 2003 - When I open files, why are some file names blue? | Excel Discussion (Misc queries) | |||
when opening an excel file, two files open | Excel Discussion (Misc queries) | |||
when opening an excel file, 2 files open (one is book1)? | Excel Discussion (Misc queries) | |||
file open via IE hyperlink causes already open files to shrink and tile | Setting up and Configuration of Excel |