Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default File Open Dialog Box


I am using the macro below to retreives the path and filename of a file
that I select from the File Open dialog box

How can I tweak this macro so that the dialog box always opens in the
C:\Employee Performance\ directory?

Any help would be much appreciatted


Sub GetFileName()
Dim sFileName As String

sFileName = Application.GetOpenFilename
If sFileName = "False" Then Exit Sub
ThisWorkbook.Activate
Range("a1").Value = sFileName
End Sub


--
Papa Waigo
------------------------------------------------------------------------
Papa Waigo's Profile: http://www.excelforum.com/member.php...o&userid=36074
View this thread: http://www.excelforum.com/showthread...hreadid=560059

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default File Open Dialog Box

Function BrowseFile() As String


Dim obOpenDialog As FileDialog
Set obOpenDialog = Application.FileDialog(msoFileDialogOpen)
While obOpenDialog.Filters.Count 0
obOpenDialog.Filters.Delete
Wend
With obOpenDialog
.InitialFileName = "C:\"
.AllowMultiSelect = False
.Filters.Add "MS Access database", "*.mdb", 1
.Filters.Add "All files", "*.*", 2
.Show

If .SelectedItems.Count 0
BrowseFile = .SelectedItems(1)

else
BrowseFile = ""
end if
End With

End Function


Papa Waigo wrote:
I am using the macro below to retreives the path and filename of a file
that I select from the File Open dialog box

How can I tweak this macro so that the dialog box always opens in the
C:\Employee Performance\ directory?

Any help would be much appreciatted


Sub GetFileName()
Dim sFileName As String

sFileName = Application.GetOpenFilename
If sFileName = "False" Then Exit Sub
ThisWorkbook.Activate
Range("a1").Value = sFileName
End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default File Open Dialog Box

Note: that GetOpenFilename is working in 97-2007 and FileDialog not (2002)

Dim FName As Variant
Dim wb As Workbook
Dim MyPath As String
Dim SaveDriveDir As String

SaveDriveDir = CurDir

MyPath = "C:\Data"
ChDrive MyPath
ChDir MyPath

FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls")
If FName < False Then
Set wb = Workbooks.Open(FName)
MsgBox "your code"
wb.Close
End If

ChDrive SaveDriveDir
ChDir SaveDriveDir


--
Regards Ron de Bruin
http://www.rondebruin.nl



"witek" wrote in message ...
Function BrowseFile() As String


Dim obOpenDialog As FileDialog
Set obOpenDialog = Application.FileDialog(msoFileDialogOpen)
While obOpenDialog.Filters.Count 0
obOpenDialog.Filters.Delete
Wend
With obOpenDialog
.InitialFileName = "C:\"
.AllowMultiSelect = False
.Filters.Add "MS Access database", "*.mdb", 1
.Filters.Add "All files", "*.*", 2
.Show

If .SelectedItems.Count 0
BrowseFile = .SelectedItems(1)

else
BrowseFile = ""
end if
End With

End Function


Papa Waigo wrote:
I am using the macro below to retreives the path and filename of a file
that I select from the File Open dialog box

How can I tweak this macro so that the dialog box always opens in the
C:\Employee Performance\ directory?

Any help would be much appreciatted


Sub GetFileName()
Dim sFileName As String

sFileName = Application.GetOpenFilename
If sFileName = "False" Then Exit Sub
ThisWorkbook.Activate
Range("a1").Value = sFileName
End Sub






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
Open Dialog Box to return Selected File Path and Not Open it. DMS Excel Programming 4 January 26th 10 12:46 PM
File open dialog box [email protected] Excel Discussion (Misc queries) 1 March 21st 07 03:01 AM
File Browse Function (Open dialog box for choosing file) b-123 Excel Programming 1 August 25th 05 10:06 PM
file open dialog sly020175 Excel Programming 1 January 13th 05 09:47 PM
open file dialog-select file-import worksheet Divinedar Excel Programming 1 January 16th 04 07:13 PM


All times are GMT +1. The time now is 08:43 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"