Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Wrong current directory

I have an Excel Workbook that is saved in a directory. It contains
a VBA macro with the following code:

Dim StartDir As String
StartDir = CurDir
MsgBox (StartDir)
.. . .

However, it says that the current directory is another one, not
the one in which the Workbook is saved.

Why would it do this?

I am new to VBA. Thanks, Alan

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Wrong current directory

maybe your file is on a different drive, i don't know because you didn't give
many details.

try this if you're looking for the current directory on another drive, such as
D, in this case.

StartDir = CurDir("D")
--


Gary


"Alan" wrote in message
...
I have an Excel Workbook that is saved in a directory. It contains
a VBA macro with the following code:

Dim StartDir As String
StartDir = CurDir
MsgBox (StartDir)
. . .

However, it says that the current directory is another one, not
the one in which the Workbook is saved.

Why would it do this?

I am new to VBA. Thanks, Alan



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Wrong current directory


Thisworkbook.path

will give you the folder where the workbook is saved. CurDir is something
else.

Tim

"Alan" wrote in message
...
I have an Excel Workbook that is saved in a directory. It contains
a VBA macro with the following code:

Dim StartDir As String
StartDir = CurDir
MsgBox (StartDir)
. . .

However, it says that the current directory is another one, not
the one in which the Workbook is saved.

Why would it do this?

I am new to VBA. Thanks, Alan



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Wrong current directory

Tim,
Thank you.

I wonder what CurDir actually is. Alan

On Jul 17, 10:28*pm, "Tim Williams" <timjwilliams at gmail dot com
wrote:
Thisworkbook.path

will give you the folder where the workbook is saved. *CurDir is something
else.

Tim

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
Change current directory to the directory that the workbook loads from! alondon Excel Programming 5 April 17th 07 06:05 AM
current directory Ross[_2_] Excel Discussion (Misc queries) 1 April 2nd 07 10:00 PM
Current Directory Mallasch Excel Discussion (Misc queries) 4 September 15th 06 03:05 AM
get current directory Souris Excel Programming 1 September 27th 05 11:53 AM
changing current directory to that of the current open file unnameable Excel Programming 2 May 19th 04 11:14 AM


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