Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 260
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 253
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
try to open excel files from explorer, 'file not found' JoM Excel Discussion (Misc queries) 2 January 24th 09 01:40 PM
Excel 2003 - When I open files, why are some file names blue? Formula One Excel Discussion (Misc queries) 2 August 17th 06 05:58 PM
when opening an excel file, two files open Brian Excel Discussion (Misc queries) 1 December 13th 05 07:24 PM
when opening an excel file, 2 files open (one is book1)? Brian Excel Discussion (Misc queries) 1 December 9th 05 11:53 PM
file open via IE hyperlink causes already open files to shrink and tile Marc Setting up and Configuration of Excel 0 May 4th 05 08:13 PM


All times are GMT +1. The time now is 09:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"