Default File Path

K

Kevin

Hello everyone from the soggy Southeast US.

I have a workbook which contains only a menu form and
supporting code. I use that menu to open a new workbook
based on a template as well as to open existing workbooks
created previously using the same template. When a new
workbook is opened I provide a name and the file is
supposed to be saved to a fixed directory that I provide.
The directory is one of my own creation, exists and is
accessible. In fact the code I am currently having
problems with worked previously. When the file is saved,
it is saved to the "C:\Program Files\Microsoft Office"
directory but it is supposed to be saved to
the "C:\Datafiles" directory.When the workbook is opened
the following code is executed:

Application.DefaultFilePath = "C:\TRUSpreadSheet\DataFiles"

To be sure the path was being saved correctly I put a
temporary field on my form and run the following code
during execution of the code to populate the field with
the default file path:

TextBox1 = Application.DefaultFilePath

Then the following code executes:

MyFName = fld_FileName & ".xls"

Set MyWkb1 = Workbooks.Open
(fileName:="C:\TRUSpreadSheet\TRUWt%Conversion.xlt")
MyWkb1.Activate

where fld_FileName is a string taken from the user on the
data input form.

Everything works properly except the location where the
field resides and when I attempt to open an existing
workbook using the getOpenFilename method it opens
the "File Open" dialog box to the "C:\Program
Files\Microsoft Office" directory.Again, this is
functionally and logically after issuing the "application.

Help! What next?

Kevin
 
G

Guest

reply form soggy southeast us
I don't know if it will help your situation but you
can goto tool>options click general tab
third box from the bottom you can set the default folder.
good look.
-----Original Message-----
Hello everyone from the soggy Southeast US.

I have a workbook which contains only a menu form and
supporting code. I use that menu to open a new workbook
based on a template as well as to open existing workbooks
created previously using the same template. When a new
workbook is opened I provide a name and the file is
supposed to be saved to a fixed directory that I provide.
The directory is one of my own creation, exists and is
accessible. In fact the code I am currently having
problems with worked previously. When the file is saved,
it is saved to the "C:\Program Files\Microsoft Office"
directory but it is supposed to be saved to
the "C:\Datafiles" directory.When the workbook is opened
the following code is executed:

Application.DefaultFilePath
= "C:\TRUSpreadSheet\DataFiles"
 
K

Kevin

I am setting that value using the command
Application.DefaultFilePath. In fact, according to the
test code I inserted, this value is set at the time the I
am either saving the new file or retrieving the file name
of the existing file.

Kevin
 

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