AW: filme in tabelle als hyperlink
17.04.2007 15:14:00
Rudi
Hallo,
ungetestet und ohne die Bilder:
In ein Modul:
Option Explicit
Public Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" (ByVal pidl As Long, _
ByVal pszPath As String) As Long
Declare Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Function GetDirectory(Optional Msg) As String
Dim bInfo As BROWSEINFO
Dim Path As String
Dim R As Long, x As Long, pos As Integer
bInfo.pidlRoot = 0&
If IsMissing(Msg) Then
bInfo.lpszTitle = "Wählen Sie bitte einen Ordner aus."
Else
bInfo.lpszTitle = Msg
End If
bInfo.ulFlags = &H1
x = SHBrowseForFolder(bInfo)
Path = Space$(512)
R = SHGetPathFromIDList(ByVal x, ByVal Path)
If R Then
pos = InStr(Path, Chr$(0))
GetDirectory = Left(Path, pos - 1)
Else
GetDirectory = ""
End If
End Function
Option Explicit
Dim wksStart As Worksheet, wksInhalt As Worksheet, vntFiles(), lngFiles As Long
Sub prcFolders()
Dim FSO As Object, oFolder As Object
Dim strFolder As String
Application.ScreenUpdating = False
Set wksStart = ThisWorkbook.Sheets("Start")
Set wksInhalt = ThisWorkbook.Sheets("Inhalt")
Set FSO = CreateObject("Scripting.FileSystemObject")
strFolder = wksStart.Cells(1, 2)
If strFolder = "" Then strFolder = GetDirectory
If strFolder = "" Then Exit Sub
GetMoreSpeed
Set oFolder = FSO.getfolder(strFolder)
lngFiles = 1
With wksInhalt
.Range("A:C").ClearContents
.Cells(1, 1) = "Pfad"
.Cells(1, 2) = "HTML"
.Cells(1, 2) = "MPG"
.Range(.Cells(1, 1), .Cells(1, 3)).Font.Bold = True
End With
prcFiles oFolder
prcSubFolders oFolder
With wksInhalt
.Range(.Cells(2, 1), .Cells(lngFiles, 3)) = WorksheetFunction.Transpose(vntFiles)
.Activate
End With
GetMoreSpeed 0
Application.ScreenUpdating = True
End Sub
Sub prcSubFolders(oFolder)
Dim oSubFolder As Object
For Each oSubFolder In oFolder.subfolders
prcFiles oSubFolder
prcSubFolders oSubFolder
Next
End Sub
Sub prcFiles(oFolder)
Dim oFile As Object
For Each oFile In oFolder.Files
If oFile.Name Like "*.mpg" Or oFile.Name Like "*.html" Then
ReDim Preserve vntFiles(1 To 3, 1 To lngFiles)
vntFiles(1, lngFiles) = oFolder.Path
If oFile.Name Like "*.html" Then
vntFiles(2, lngFiles) = "=hyperlink(""" & oFile.Path & """;""" & oFile.Name & """)"
ElseIf oFile.Name Like "*.html" Then
vntFiles(3, lngFiles) = "=hyperlink(""" & oFile.Path & """;""" & oFile.Name & """)"
End If
lngFiles = lngFiles + 1
End If
Next
End Sub
Sub GetMoreSpeed(Optional ByVal Modus As Integer = 1)
Static lngCalc As Long
With Application
If Modus = 1 Then
lngCalc = .Calculation
.ScreenUpdating = False
.EnableEvents = False
.DisplayAlerts = False
.Calculation = -4135
.Cursor = xlWait
Else
.ScreenUpdating = True
.EnableEvents = True
.DisplayAlerts = True
.Calculation = IIf(lngCalc 0, lngCalc, -4105)
.Cursor = xlDefault
End If
End With
End Sub
Starten musst du prcFolders()
Gruß
Rudi
Eine Kuh macht Muh, viele Kühe machen Mühe