Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Update CurDIr??

I have written the following code to open a file:

Workbooks.Open Filename:=CurDir & "\FILENAME.XLS"

This was created in a folder on my hard drive, but now that I have moved
everything to a network drive I get errors saying that the file does not
exist because the location is still saved as my hard drive folder.

Is there a command I should be using to update everything before running, or
maybe a better way to name the files that I should be using?


Thanks,
Nick M
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Update CurDIr??

curdir returns the current directory for the default drive.

Why not just spell out where you want to open the file

Workbooks.Open Filename:="S:\Myfolder\Filename.xls"

--
Regards,
Tom Ogilvy


"Nick M" wrote:

I have written the following code to open a file:

Workbooks.Open Filename:=CurDir & "\FILENAME.XLS"

This was created in a folder on my hard drive, but now that I have moved
everything to a network drive I get errors saying that the file does not
exist because the location is still saved as my hard drive folder.

Is there a command I should be using to update everything before running, or
maybe a better way to name the files that I should be using?


Thanks,
Nick M

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Update CurDIr??

That would be ideal, but this is for a somewhat standardized process that has
to be able to be moved depending on when it is used.

"Tom Ogilvy" wrote:

curdir returns the current directory for the default drive.

Why not just spell out where you want to open the file

Workbooks.Open Filename:="S:\Myfolder\Filename.xls"

--
Regards,
Tom Ogilvy


"Nick M" wrote:

I have written the following code to open a file:

Workbooks.Open Filename:=CurDir & "\FILENAME.XLS"

This was created in a folder on my hard drive, but now that I have moved
everything to a network drive I get errors saying that the file does not
exist because the location is still saved as my hard drive folder.

Is there a command I should be using to update everything before running, or
maybe a better way to name the files that I should be using?


Thanks,
Nick M

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Update CurDIr??

In the workbook open event store the file path in a convenient location in
the workbook.

Use this to refer to files when you are opening and saving them.

The first time the file is opened from the windows explorer the current
location will be stored.

You can also test for and create new sub directories in the application root
directory if required in the open event.

Works a treat in my applications

--
Cheers
Nigel



"Nick M" wrote in message
...
I have written the following code to open a file:

Workbooks.Open Filename:=CurDir & "\FILENAME.XLS"

This was created in a folder on my hard drive, but now that I have moved
everything to a network drive I get errors saying that the file does not
exist because the location is still saved as my hard drive folder.

Is there a command I should be using to update everything before running,
or
maybe a better way to name the files that I should be using?


Thanks,
Nick M



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Update CurDIr??

If curdir doesn't give the correct answer, then:

thisworkbook.Path gives the path of the workbook executing the code.

application.Path the location of the Excel.exe file

Activeworkbook.path of the workbook that is active.

Application.DefaultFilePath gives the default path used for files when
excel is first started. (found in Tools=Options=General Tab, "default file
location""



Perhaps you can use one of those.

--
Regards,
Tom Ogilvy


"Nick M" wrote:

That would be ideal, but this is for a somewhat standardized process that has
to be able to be moved depending on when it is used.

"Tom Ogilvy" wrote:

curdir returns the current directory for the default drive.

Why not just spell out where you want to open the file

Workbooks.Open Filename:="S:\Myfolder\Filename.xls"

--
Regards,
Tom Ogilvy


"Nick M" wrote:

I have written the following code to open a file:

Workbooks.Open Filename:=CurDir & "\FILENAME.XLS"

This was created in a folder on my hard drive, but now that I have moved
everything to a network drive I get errors saying that the file does not
exist because the location is still saved as my hard drive folder.

Is there a command I should be using to update everything before running, or
maybe a better way to name the files that I should be using?


Thanks,
Nick M



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Update CurDIr??

Thank you! thisworkbook.path should do it for me. All the 'working files'
get moved in a group, and I though this is what I though CurDir was being
used to do.

Thanks again,
Nick M.

"Tom Ogilvy" wrote:

If curdir doesn't give the correct answer, then:

thisworkbook.Path gives the path of the workbook executing the code.

application.Path the location of the Excel.exe file

Activeworkbook.path of the workbook that is active.

Application.DefaultFilePath gives the default path used for files when
excel is first started. (found in Tools=Options=General Tab, "default file
location""



Perhaps you can use one of those.

--
Regards,
Tom Ogilvy


"Nick M" wrote:

That would be ideal, but this is for a somewhat standardized process that has
to be able to be moved depending on when it is used.

"Tom Ogilvy" wrote:

curdir returns the current directory for the default drive.

Why not just spell out where you want to open the file

Workbooks.Open Filename:="S:\Myfolder\Filename.xls"

--
Regards,
Tom Ogilvy


"Nick M" wrote:

I have written the following code to open a file:

Workbooks.Open Filename:=CurDir & "\FILENAME.XLS"

This was created in a folder on my hard drive, but now that I have moved
everything to a network drive I get errors saying that the file does not
exist because the location is still saved as my hard drive folder.

Is there a command I should be using to update everything before running, or
maybe a better way to name the files that I should be using?


Thanks,
Nick M

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
CurDir Bryan Brassell Excel Programming 5 April 2nd 06 09:59 PM
CurDir CLR Excel Programming 3 December 21st 05 06:49 PM
Curdir Jos Vens[_2_] Excel Programming 2 March 29th 05 12:53 PM
CurDir does not work Jim73 Excel Programming 3 January 12th 05 08:15 AM
CurDir vi_sh_wa Excel Programming 2 December 14th 04 08:17 AM


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

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"