Jeden Sheets Pfad angeben
20.02.2008 07:20:00
Heinz
Habe im unteren Code, Mp3 Files zum einlesen.
Muss aber immer den Pfad immer über Ordner suchen eingeben.
Ich möchte aber,das ich den Pfad in jeden Sheets fix eingebe.
ZB. C:/Test/2007
Könnte mir dazu bitte jemand weiterhelfen.
Danke & Gruß Heinz
Private Sub CommandButton1_Click()
'
Private Sub Einlesen_Click()
Application.ScreenUpdating = False
Dim strInitialDir As String, strPath As String
Dim sFile As String, sPattern As String, sPath As String
Dim iRow As Integer
'Columns(1).ClearContents
sPath = BrowseDirectory()
If sPath = "" Then Exit Sub
'einlesen
If Right(sPath, 1) "\" Then sPath = sPath & "\"
sPattern = "*.mp3" 'hier den typ ändern zb doc txt unsw.
sFile = Dir(sPath & sPattern)
Do Until sFile = ""
iRow = iRow + 1
ActiveSheet.Hyperlinks.Add Anchor:=Cells(iRow, 4), _
Address:=sPath & sFile, TextToDisplay:=sFile
sFile = Dir()
Loop
Columns("D:D").Select
Selection.Replace What:=".mp3", Replacement:=" ", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Font.Underline = xlUnderlineStyleSingle
Selection.Font.Underline = xlUnderlineStyleNone
Columns("D:D").EntireColumn.AutoFit
Range("B3").Select
Application.ScreenUpdating = True
End Sub