Dateinamen ermitteln aus Pfad

  • Excel

Es gibt 5 Antworten in diesem Thema. Der letzte Beitrag () ist von rgomez.

    Dateinamen ermitteln aus Pfad

    Guten Tag!

    Habe folgendes Anliegen.

    Ich habe eine Excel-Tabelle und importiere in eine Excel-Tabelle Inhalte aus einem anderen Excelblatt.

    Die Master-Excel-Tabelle hat einen Button, wenn ich den Button drücke öffnet sich ein Filedialogfeld mit der ich die Datei importieren kann.

    Das mache ich so:

    Quellcode

    1. ​ImportDatei = Application.GetOpenFilename(Title:="Eine Datei auswählen")


    Nun habe ich in der "ImportDatei" die Variable des Pfads.

    Es ist aber so, dass diese Variable sehr lang ist und ich brauche aber NUR den Dateiname und nicht den kompletten Pfad + Dateiendungskürzel.

    Gibt es da einen Trick, dass man wirklich NUR den Dateinamen hat in der Variable ???

    Vielen Dank!
    So funktioniert die "Split" Variante. Bin in VBA gerade nicht so drin daher weiß ich nicht ab es da ne Entsprechung zur Klasse File gibt.

    ImoprtDaite Split bei "/" und der letzte Eintrag ist deine Datei
    LetzterEintrag Split bei "." und alles außer dem letzten Eintrag ist dein Dateiname
    There is no CLOUD - just other people's computers

    Q: Why do JAVA developers wear glasses?
    A: Because they can't C#

    Daily prayer:
    "Dear Lord, grand me the strength not to kill any stupid people today and please grant me the ability to punch them in the face over standard TCP/IP."
    @petaod Deine Prüfen fällt bei der Datei "C:\Temp\Mappe.Neu.April.xls" aber auf die Nase
    There is no CLOUD - just other people's computers

    Q: Why do JAVA developers wear glasses?
    A: Because they can't C#

    Daily prayer:
    "Dear Lord, grand me the strength not to kill any stupid people today and please grant me the ability to punch them in the face over standard TCP/IP."
    Hi! :)
    ich glaube was du suchst ist

    VB.NET-Quellcode

    1. Dim FSO as New FileSystemObject
    2. Dim fileName as String
    3. fileName = FSO.GetFileName(Application.GetOpenFilename(Title:="Eine Datei auswählen"))


    Hier mehr:
    msdn.microsoft.com/en-us/library/office/gg264499.aspx
    Life doesn't give you a datasheet. Sometimes the docs are wrong and you have to try it.

    Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von „rgomez“ ()