Office Logo  Zurück zur Hauptseite

Relative Pfade

       Allgemeines über relative Pfade

       Was ist eine relative Pfadangabe?

       Wozu sind relative Pfadangaben nützlich?

       Die Liste der zuletzt verwendeten Dateien in Microsoft Excel

       Relative Links in Microsoft Excel

 

      Home Zur Hauptseite

To Top

Diese Seite ist in Bearbeitung!

Allgemeines über relative Pfade

Relative Pfade werden eigentlich eher selten benutzt, da man gewöhnlich den so genannten absoluten Pfad kennt und somit - wenn benötigt - auch angeben kann.

To Top

 


Was ist eine relative Pfadangabe?

Das Gegenteil von "relativer Pfad" ist "absoluter Pfad". Häufig findet man anstelle von "absolut" auch die Bezeichnung/Umschreibung "vollständig und eindeutig".

Ein relativer Pfad bezieht sich auf das aktuelle Verzeichnis oder auf ein explizit angegebenes Basis-Verzeichnis.

 

Beispiele

Aktuelles Verzeichnis Relativer Pfad Absoluter Pfad
C:\Daten ..\Mappe.xls C:\Mappe.xls
C:\Daten ..\Backup\Mappe.xls C:\Backup\Mappe.xls
C:\Daten Backup\Mappe.xls C:\Daten\Backup\Mappe.xls

 

Beispiele

Relativer Pfad Absoluter Pfad
C:\Daten\Backup\..\Mappe.xls C:\Daten\Mappe.xls

To Top

 


Wozu sind relative Pfadangaben nützlich?

Das Basis-Verzeichnis kann unterschiedlich sein.

 

Relative Pfade in einem VBA-Programm

Auch in einem VBA-Programm kann man relative Pfade verwenden.

 

VBA-Befehle/-Funktionen und relative Pfade

Es gibt eine ganze Reihe VBA-Befehle und -Funktionen, die relative Pfade akzeptieren.

 

VBA-Befehl MkDir

VBA-Befehl Open

VBA-Befehl ChDir

VBA-Befehl RmDir

VBA-Funktion GetAttr

 

MkDir "C:\Daten\Excel\Neuer Ordner"

MkDir "Neuer Ordner"

 

Open "Backup\Textdatei.txt" For Input As #1

 

 

MsgBox CreateObject("Scripting.FileSystemObject").GetAbsolutePathName("")
MsgBox CreateObject("Scripting.FileSystemObject").GetAbsolutePathName("BlaBla")
MsgBox CreateObject("Scripting.FileSystemObject").GetAbsolutePathName("D:\Bla\..\Irgendwas\Datei.txt")
MsgBox CreateObject("Scripting.FileSystemObject").GetAbsolutePathName("..")
MsgBox CreateObject("Scripting.FileSystemObject").GetAbsolutePathName("\")

To Top

 


Die Liste der zuletzt verwendeten Dateien in Microsoft Excel

Die in der Liste der zuletzt verwendeten Dateien angegebenen Dateipfade werden relativ zum aktuellen Pfad angegeben. Der aktuelle Pfad kann mit CurDir ermittelt werden. Beachten Sie auch, dass der aktuelle Pfad immer dem aktuellen Standardarbeitsverzeichnis von Microsoft Excel entspricht.

Liste der zuletzt verwendeten Dateien

 

Die Name-Eigenschaft liefert den Datei-Eintrag so, wie er in der Liste angezeigt wird, d.h. mit einer relativen Pfadangabe:

?Application.RecentFiles(1).Name
SOSCQ\WSH_Runtime-Test.xls

Etwas ungewöhnlich ist, dass die Name-Eigenschaft nicht nur den Dateinamen enthält. Je nach aktuellem Standardarbeitsverzeichnis werden auch Teile des Dateipfades zurückgegeben.

 

 

Die Path-Eigenschaft liefert den vollständigen Pfad zur Datei:

?Application.RecentFiles(1).Path
D:\NeueDaten\SOSCQ\WSH_Runtime-Test.xls

 

Weitere Informationen

Excel-Objektmodell: Eigenschaften des Application-Objektes

VBA-Befehle und -Funktionen

To Top

 


Relative Links in Microsoft Excel

In Microsoft Excel, you can link a cell in a workbook to another workbook using a formula that references the external workbook. When this link is created, it may use a relative path. With a relative link, you can move the workbooks without breaking the link. This article discusses how the references to linked workbooks are stored by Excel in different circumstances.

Links to external workbooks are created in a relative manner whenever possible. This means that the full path to the source data file is not recorded, but rather the portion of the path as it relates to the linked workbook. With this method, you can move the workbooks without breaking the links between them. The links remain intact, however, only if the workbooks remain in the same location relative to each other. For example, if the linked file is C:\Mydir\Linked.xls and the source data file is C:\Mydir\Files\Source.xls, you can move the files to the D drive as long as the source file is still located in a subfolder called "files".

Relative links may cause problems if you move the linked file to different computers and the source is in a central location. In this case, it may be helpful to create absolute links. To create an absolute link, use a Universal Naming Convention (UNC) path. When you type a link by using a UNC path, Excel stores the whole path. The path remains absolute regardless of where it is opened from or how it is opened.

When Excel stores the path to a linked file, it uses the following rules to determine what to store.

NOTE: Moving up a path indicates that you are referring to folders moving away from the root drive or share. Moving down a path indicates that you are moving closer to the root drive or share.

It is also important to note that what appears in the formula bar is not necessarily what is stored. For example, if the source data file is closed, you see a full path to the file, although only the file name may be stored.

 

XL (all Versions): Description of Link Management and Storage in Excel
http://support.microsoft.com/?scid=kb;en-us;328440

To Top

 


WIN: Command-Line Switches for Windows Explorer
http://support.microsoft.com/?kbid=130510

 

To Top

Haben Sie Fragen, Anregungen oder Hinweise?
Senden Sie mir eine Mail

Zuletzt aktualisiert am 24.01.2004 / 22:15 Uhr
Zuletzt kontrolliert am 01.01.2009 / 10:00 Uhr
© 2002-2009 by Philipp von Wartburg, Schweiz