Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Finding Current Path | Excel Programming | |||
Current Workbook Path | Excel Programming | |||
Current Workbook Path | Excel Programming | |||
Current Workbook Path | Excel Programming | |||
Current path to Qualified Path | Excel Programming |