Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default GetOpenFilename with default filename?

I'm trying to adopt the Application.GetOpenFilename method, so I can let go of the dependency for comdlg32.ocx, which is not included in Vista. However, I haven't found a way to have GetOpenFilename start with a default filename. Starting in a given directory works (if I call it before calling GetOpenFilename), but I wonder if it's possible to have the dialog box open with a default filename in that directory? That is, when the dialog opens (in the given directory), the default file should be pre-selected. Is that possible?

Gustaf
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default GetOpenFilename with default filename?

You need to use chdrive and chdir before calling the getopenfilename.

chdrive("h:")
chdir("temp")

"Gustaf" wrote:

I'm trying to adopt the Application.GetOpenFilename method, so I can let go of the dependency for comdlg32.ocx, which is not included in Vista. However, I haven't found a way to have GetOpenFilename start with a default filename. Starting in a given directory works (if I call it before calling GetOpenFilename), but I wonder if it's possible to have the dialog box open with a default filename in that directory? That is, when the dialog opens (in the given directory), the default file should be pre-selected. Is that possible?

Gustaf

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default GetOpenFilename with default filename?

Thank you, but maybe you didn't read the question in detail. I'm not asking for default directory, but default filename. Also, when you open default directory, I have found it better to call

Private Declare Function SetCurrentDirectory Lib "kernel32" Alias "SetCurrentDirectoryA" (ByVal lpPathName As String) As Long

rather than ChDir(). It works with UNC (network) paths too.

If the answer to my question is "you can't do that", that would be okay too.

Gustaf

Joel wrote:
You need to use chdrive and chdir before calling the getopenfilename.


chdrive("h:") chdir("temp")

"Gustaf" wrote:

I'm trying to adopt the Application.GetOpenFilename method, so I
can let go of the dependency for comdlg32.ocx, which is not
included in Vista. However, I haven't found a way to have
GetOpenFilename start with a default filename. Starting in a given
directory works (if I call it before calling GetOpenFilename), but
I wonder if it's possible to have the dialog box open with a
default filename in that directory? That is, when the dialog opens
(in the given directory), the default file should be pre-selected.
Is that possible?

Gustaf

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default GetOpenFilename with default filename?

i tried various alternatives to
"Text Files (*.txt), *.txt")

eg

"Excel Files (*.xls),abc.xls"

but they don't "pre select" the required file.
so i guess it can't be done.



"Gustaf" wrote in message
...
Thank you, but maybe you didn't read the question in detail. I'm not
asking for default directory, but default filename. Also, when you open
default directory, I have found it better to call

Private Declare Function SetCurrentDirectory Lib "kernel32" Alias
"SetCurrentDirectoryA" (ByVal lpPathName As String) As Long

rather than ChDir(). It works with UNC (network) paths too.

If the answer to my question is "you can't do that", that would be okay
too.

Gustaf

Joel wrote:
You need to use chdrive and chdir before calling the getopenfilename.


chdrive("h:") chdir("temp")

"Gustaf" wrote:

I'm trying to adopt the Application.GetOpenFilename method, so I
can let go of the dependency for comdlg32.ocx, which is not
included in Vista. However, I haven't found a way to have
GetOpenFilename start with a default filename. Starting in a given
directory works (if I call it before calling GetOpenFilename), but
I wonder if it's possible to have the dialog box open with a
default filename in that directory? That is, when the dialog opens
(in the given directory), the default file should be pre-selected.
Is that possible?

Gustaf

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default GetOpenFilename with default filename?

You can use the filedialog instead

ChDrive ("c:\")
ChDir ("c:\temp")
Set filetoopen = Application.FileDialog(msoFileDialogOpen)
filetoopen.InitialFileName = "book1.xls"
filetoopen.Show

"Gustaf" wrote:

Thank you, but maybe you didn't read the question in detail. I'm not asking for default directory, but default filename. Also, when you open default directory, I have found it better to call

Private Declare Function SetCurrentDirectory Lib "kernel32" Alias "SetCurrentDirectoryA" (ByVal lpPathName As String) As Long

rather than ChDir(). It works with UNC (network) paths too.

If the answer to my question is "you can't do that", that would be okay too.

Gustaf

Joel wrote:
You need to use chdrive and chdir before calling the getopenfilename.


chdrive("h:") chdir("temp")

"Gustaf" wrote:

I'm trying to adopt the Application.GetOpenFilename method, so I
can let go of the dependency for comdlg32.ocx, which is not
included in Vista. However, I haven't found a way to have
GetOpenFilename start with a default filename. Starting in a given
directory works (if I call it before calling GetOpenFilename), but
I wonder if it's possible to have the dialog box open with a
default filename in that directory? That is, when the dialog opens
(in the given directory), the default file should be pre-selected.
Is that possible?

Gustaf




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default GetOpenFilename with default filename?

This is exactly what I needed. Thank you very much!

Gustaf

Joel wrote:
You can use the filedialog instead

ChDrive ("c:\")
ChDir ("c:\temp")
Set filetoopen = Application.FileDialog(msoFileDialogOpen)
filetoopen.InitialFileName = "book1.xls"
filetoopen.Show

"Gustaf" wrote:

Thank you, but maybe you didn't read the question in detail. I'm not asking for default directory, but default filename. Also, when you open default directory, I have found it better to call

Private Declare Function SetCurrentDirectory Lib "kernel32" Alias "SetCurrentDirectoryA" (ByVal lpPathName As String) As Long

rather than ChDir(). It works with UNC (network) paths too.

If the answer to my question is "you can't do that", that would be okay too.

Gustaf

Joel wrote:
You need to use chdrive and chdir before calling the getopenfilename.


chdrive("h:") chdir("temp")

"Gustaf" wrote:

I'm trying to adopt the Application.GetOpenFilename method, so I
can let go of the dependency for comdlg32.ocx, which is not
included in Vista. However, I haven't found a way to have
GetOpenFilename start with a default filename. Starting in a given
directory works (if I call it before calling GetOpenFilename), but
I wonder if it's possible to have the dialog box open with a
default filename in that directory? That is, when the dialog opens
(in the given directory), the default file should be pre-selected.
Is that possible?

Gustaf

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
GetOpenFilename path vs filename Bob Zimski Excel Programming 5 February 24th 09 07:29 PM
Using filename retrieved from GetOpenFilename Horatio J. Bilge, Jr. Excel Discussion (Misc queries) 2 September 12th 08 07:47 PM
Set Location and Filename to replace GetOpenFilename David Excel Programming 3 June 1st 05 02:29 PM
GetopenFilename default path Srinath Excel Programming 5 October 10th 03 04:47 PM
GetOpenFilename - Default Folder Andy Excel Programming 3 September 19th 03 04:20 PM


All times are GMT +1. The time now is 09:37 AM.

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

About Us

"It's about Microsoft Excel"