how set default path?

G

Guest

Thanks for any help.
I have a macro in a workbook that opens a workbook, gets some numbers out of
it, then opens another workbook, and puts the numbers in.
I could do this by hand, but there are about 15 numbers, and for once a day,
so I figure I can save some time by automating it.
The way I open the file is use getOpenFilename.
The thing is, everytime I run the macro, I have to change to the directory.
And the file I need is 4 or 5 folders down. Which takes a couple of seconds.
So I figure there is gotta be some way to set the default path so that when I
do the getOpenFilename method, it already shows the path I set in the code
just before that.
Here's the code:
....
MyFile = Application.GetOpenFilename("Microsoft Excel Application (*.xls),
*.mdb", , , , False)
Workbooks.Open MyFile
'get numbers
MyFile = Application.GetOpenFilename("Microsoft Excel Application (*.xls),
*.mdb", , , , False)
Workbooks.Open MyFile
'write numbers
I typically do this batch, for about 20 files one after another, so I only
have to set the folder the first time, but since I do the GetOpenFilename
method twice, each time I have to do about 5 or 6 clicks to get back to that
directory.
Is there someway to set the path so that when the dialog box opens, the path
is already set?
Another way I thought of doing this is not using getOpenFilename but
somekind of inputBox and a path, but I would like to try it this way.
Thanks again.
 
G

Guest

Ian Elliott said:
Thanks for any help.
I have a macro in a workbook that opens a workbook, gets some numbers out of
it, then opens another workbook, and puts the numbers in.
I could do this by hand, but there are about 15 numbers, and for once a day,
so I figure I can save some time by automating it.
The way I open the file is use getOpenFilename.
The thing is, everytime I run the macro, I have to change to the directory.
And the file I need is 4 or 5 folders down. Which takes a couple of seconds.
So I figure there is gotta be some way to set the default path so that when I
do the getOpenFilename method, it already shows the path I set in the code
just before that.
Here's the code:
...
MyFile = Application.GetOpenFilename("Microsoft Excel Application (*.xls),
*.mdb", , , , False)
Workbooks.Open MyFile
'get numbers
MyFile = Application.GetOpenFilename("Microsoft Excel Application (*.xls),
*.mdb", , , , False)
Workbooks.Open MyFile
'write numbers
I typically do this batch, for about 20 files one after another, so I only
have to set the folder the first time, but since I do the GetOpenFilename
method twice, each time I have to do about 5 or 6 clicks to get back to that
directory.
Is there someway to set the path so that when the dialog box opens, the path
is already set?
Another way I thought of doing this is not using getOpenFilename but
somekind of inputBox and a path, but I would like to try it this way.
Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top