Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default How to get the current path

I've created a shortcut of an Excel sheet (e.g. Example.xls). On the
shortcut I do a right mouse click and then click properties. In 'Start
in:' I type 'C:\Temp'. Now I double click the shortcut 'Example.xls'
and like to get the current path (in this example 'C:\Temp').

In real VB I do it with a FileListBox:
MsgBox (FileListBox1.Path)

But how can I do it in VBA (e.g. Excel)?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default How to get the current path

Stefan,

You can use the CurDir function to get the current directory..


--
Hope that helps.

Vergel Adriano


"Stefan Mueller" wrote:

I've created a shortcut of an Excel sheet (e.g. Example.xls). On the
shortcut I do a right mouse click and then click properties. In 'Start
in:' I type 'C:\Temp'. Now I double click the shortcut 'Example.xls'
and like to get the current path (in this example 'C:\Temp').

In real VB I do it with a FileListBox:
MsgBox (FileListBox1.Path)

But how can I do it in VBA (e.g. Excel)?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default How to get the current path

Thanks for your reply.

CurDir is not bad but it doesn't really care what is written in 'Start
in:' resp. from which path I've startet the Excel workbook.

If I start the Excel workbook e.g. from the Desktop it should show 'C:
\Documents and Settings\Administrator\Desktop'.
If in 'Start in:' of the shortcut of the Excel workbook is written 'C:
\Temp' it should show 'C:\Temp'.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default How to get the current path

activeworkbook.Path


--


Gary


"Stefan Mueller" wrote in message
oups.com...
I've created a shortcut of an Excel sheet (e.g. Example.xls). On the
shortcut I do a right mouse click and then click properties. In 'Start
in:' I type 'C:\Temp'. Now I double click the shortcut 'Example.xls'
and like to get the current path (in this example 'C:\Temp').

In real VB I do it with a FileListBox:
MsgBox (FileListBox1.Path)

But how can I do it in VBA (e.g. Excel)?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default How to get the current path

ActiveWorkbook.Path is closer to my wanted function than CurDir
because it shows e.g. 'C:\Documents and Settings\Administrator
\Desktop' if I start the Excel workbook from the Desktop.
However, it doesn't show 'C:\Temp' if in 'Start in:' of the shortcut
of the Excel workbook is written 'C:\Temp'.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default How to get the current path

if i open a workbook from c:\temp it returns c:\temp

from the immediate window

?activeworkbook.Path
C:\Temp

--


Gary


"Stefan Mueller" wrote in message
ups.com...
ActiveWorkbook.Path is closer to my wanted function than CurDir
because it shows e.g. 'C:\Documents and Settings\Administrator
\Desktop' if I start the Excel workbook from the Desktop.
However, it doesn't show 'C:\Temp' if in 'Start in:' of the shortcut
of the Excel workbook is written 'C:\Temp'.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How to get the current path

I don't think that the workbook file itself is in C:\temp. The workbook could
be anywhere. But there's a shortcut on the desktop that points to the correct
location.

But inside that shortcut (rightclick on it and choose properties, then Shortcut
tab) you'll see another spot to specify a "start in" folder.

I have no idea how to get that information based on the opened workbook.

Gary Keramidas wrote:

if i open a workbook from c:\temp it returns c:\temp

from the immediate window

?activeworkbook.Path
C:\Temp

--

Gary

"Stefan Mueller" wrote in message
ups.com...
ActiveWorkbook.Path is closer to my wanted function than CurDir
because it shows e.g. 'C:\Documents and Settings\Administrator
\Desktop' if I start the Excel workbook from the Desktop.
However, it doesn't show 'C:\Temp' if in 'Start in:' of the shortcut
of the Excel workbook is written 'C:\Temp'.


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default How to get the current path

Like already mentioned, in real VB the FileListBox (FileListBox1.Path)
shows this information.
Unfortunately there's no FileListBox in VBA. Therefore I'm looking for
another way to get this information.

ActiveWorkbook.Path is fine if you start the real Excel sheet. But it
does not work if you start the Excel sheet via a shotcut. In that case
ActiveWorkbook.Path still shows the path where the real Excel sheet is
located and not where the shortcut is located resp. what is defined in
'Start in:'.

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
Finding Current Path Mike C Excel Programming 1 April 7th 05 09:14 PM
Current Workbook Path MarkTheNuke Excel Programming 0 February 21st 05 04:33 AM
Current Workbook Path windsurferLA Excel Programming 1 February 19th 05 04:19 PM
Current Workbook Path MarkTheNuke Excel Programming 0 February 19th 05 06:31 AM
Current path to Qualified Path Mary Excel Programming 1 October 14th 04 02:42 PM


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