Moderatori: Anthony47, Flash30005
Sub prova()
Dim strFile As String
Dim stdPic As StdPicture
Dim lngWidth As Long
Dim lngHeight As Long
Dim strPath As String
Dim intRow As Integer
strPath = "c:\prova" '<==== Modifica con tua directoy
strFile = Dir$(strPath & "\*.jpg") '
Do While Len(strFile)
Set stdPic = LoadPicture(strPath & "\" & strFile)
intRow = intRow + 1
Range("A" & intRow).Value = strFile
Range("B" & intRow).Value = Round(stdPic.Width / 26.4583)
Range("C" & intRow).Value = Round(stdPic.Height / 26.4583)
strFile = Dir$
Loop
End Sub
strFile = Dir$(strPath & "\*.jpg")
strFile = Dir$(strPath & "\*.*")
strPath = "c:\prova" '<==== Modifica con tua directoy
allpics = Array("*.jpg", "*.png", "*.gif") '<<< Altri formati? '***
For Each itm In allpics '***
strFile = Dir$(strPath & "\" & itm) ' '***
Do While Len(strFile)
Set stdPic = LoadPicture(strPath & "\" & strFile)
intRow = intRow + 1
Range("A" & intRow).Value = strFile
Range("B" & intRow).Value = Round(stdPic.Width / 26.4583)
Range("C" & intRow).Value = Round(stdPic.Height / 26.4583)
strFile = Dir$
Loop
Next itm '***
recalcatiiti ha scritto:Ciao a tutti, provo ad alzare un po' (tanto) la posta.
se non volessi limitarmi alla sola cartella, ma anche a tutte le sotto cartelle e ad eventuali sotto-...-sotto-cartelle?
In sostanza: è possibile elencare tutte le immagini del mio hard disk (con relative dimensioni e peso in kb) in un colpo solo senza modificare il percorso? Mi sembra infattibile ma sarebbe fantastico.
Grazie e ciao.
Dim myFso As Object, ccAll As Long 'RIGOROSAMENTE IN TESTA AL MODULO
Function RecurDir(ByVal ccDir As String, myExt As Variant, ByRef cStore As Variant) As String
Dim myItm
'
If myFso Is Nothing Then Set myFso = CreateObject("Scripting.FileSystemObject")
If myFso Is Nothing Then Beep
DoEvents
On Error GoTo Mahh
For Each myItm In myFso.GetFolder(ccDir).Files
ccAll = ccAll + 1
mysplit = Split(" " & myItm, ".", , vbTextCompare)
If Not IsError(Application.Match(mysplit(UBound(mysplit)), myExt, 0)) Then
myind = UBound(cStore)
ReDim Preserve cStore(1 To myind + 1)
cStore(myind) = myItm
End If
Mahh:
Resume Bohh
Bohh:
Next myItm
For Each myItm In myFso.GetFolder(ccDir).SubFolders
Call RecurDir(myItm, myExt, cStore)
Next myItm
End Function
Dim FArr() As String
ReDim FArr(1 To 1)
allpics = Array("jpg", "png", "gif") '<<< Altri formati? '***
StrDir=" C:\PERCORSO\Documents" '<<< Il Percorso iniziale
Call RecurDir(StrDir, allpics, FArr)
For I=1 to ubound(FArr)
If len(fArr(i)>0 then
'qui le istruzioni prima inserite nel Do While /Loop
End If
Next I
Dim myFso As Object, ccAll As Long 'RIGOROSAMENTE IN TESTA AL MODULO
Function RecurDir(ByVal ccDir As String, myExt As Variant, ByRef cStore As Variant) As String
Dim myItm
'
If myFso Is Nothing Then Set myFso = CreateObject("Scripting.FileSystemObject")
If myFso Is Nothing Then Beep
DoEvents
On Error GoTo Mahh
For Each myItm In myFso.GetFolder(ccDir).Files
ccAll = ccAll + 1
mysplit = Split(" " & myItm, ".", , vbTextCompare)
If Not IsError(Application.Match(mysplit(UBound(mysplit)), myExt, 0)) Then
myind = UBound(cStore)
ReDim Preserve cStore(1 To myind + 1)
cStore(myind) = myItm
End If
Mahh:
Resume Bohh
Bohh:
Next myItm
For Each myItm In myFso.GetFolder(ccDir).SubFolders
Call RecurDir(myItm, myExt, cStore)
Next myItm
End Function
Sub prova()
Dim strFile As String
Dim stdPic As StdPicture
Dim lngWidth As Long
Dim lngHeight As Long
Dim strPath As String
Dim intRow As Integer
Dim FArr() As String
ReDim FArr(1 To 1)
allpics = Array("jpg", "png", "gif") '<<< Altri formati? '***
StrDir = "c:\prova" '<<< Il Percorso iniziale
Call RecurDir(StrDir, allpics, FArr)
For Each itm In allpics '***
strFile = Dir$(strPath & "\" & itm) ' '***
For i = 1 To UBound(FArr)
If Len(FArr(i)) > 0 Then
Set stdPic = LoadPicture(strPath & "\" & strFile) '<--------------------
intRow = intRow + 1
Range("A" & intRow).Value = strFile
Range("B" & intRow).Value = Round(stdPic.Width / 26.4583)
Range("C" & intRow).Value = Round(stdPic.Height / 26.4583)
strFile = Dir$
End If
Next i
Next itm
End Sub
Sub prova()
Dim strFile As String
Dim stdPic As StdPicture
Dim lngWidth As Long
Dim lngHeight As Long
Dim strPath As String
Dim intRow As Integer
Dim FArr() As String
ReDim FArr(1 To 1)
allpics = Array("jpg", "png", "gif") '<<< Altri formati? '***
StrDir = "c:\prova" '<<< Il Percorso iniziale
Call RecurDir(StrDir, allpics, FArr)
For i = 1 To UBound(FArr)
If Len(FArr(i)) > 0 Then
intRow = intRow + 1
Range("A" & intRow).Value = FArr(i)
On Error GoTo piPP
Set stdPic = LoadPicture(FArr(i)) '<--------------------
Range("B" & intRow).Value = Round(stdPic.Width / 26.4583)
Range("C" & intRow).Value = Round(stdPic.Height / 26.4583)
' strFile = Dir$
piPP:
Resume poPP
poPP:
End If
Next i
End Sub
Eh, tutto bene fino a "End Function", poi....
FileLen( file_path )
Sub prova()
Dim strFile As String
Dim stdPic As StdPicture
Dim lngWidth As Long
Dim lngHeight As Long
Dim strPath As String
Dim intRow As Integer
Dim FArr() As String
ReDim FArr(1 To 1)
allpics = Array("jpg", "png", "gif") '<<< Altri formati? '***
StrDir = "c:\prova" '<<< Il Percorso iniziale
Call RecurDir(StrDir, allpics, FArr)
For i = 1 To UBound(FArr)
If Len(FArr(i)) > 0 Then
intRow = intRow + 1
mysplit = Split(FArr(i), "\", , vbTextCompare)
If UBound(mysplit) > 0 Then Range("B" & intRow).Value = mysplit(UBound(mysplit))
Range("A" & intRow).Value = Replace(FArr(i), "\" & mysplit(UBound(mysplit)), "\", , , vbTextCompare)
Range("E" & intRow).Value = myFso.getfile(FArr(i)).Size
On Error GoTo piPP
Set stdPic = LoadPicture(FArr(i)) '<--------------------
Range("C" & intRow).Value = Round(stdPic.Width / 26.4583)
Range("D" & intRow).Value = Round(stdPic.Height / 26.4583)
' strFile = Dir$
piPP:
Resume poPP
poPP:
End If
Next i
On Error Resume Next
Set myFso = Nothing
On Error GoTo 0
End Sub
Torna a Applicazioni Office Windows
Importare immagini a seconda del testo in una cella Autore: Paolo67met |
Forum: Applicazioni Office Windows Risposte: 4 |
Salvare file excel in formato html escludendo le immagini Autore: systemcrack |
Forum: Applicazioni Office Windows Risposte: 10 |
Visualizzatore immagini W 10 problemi Autore: mastino46 |
Forum: Audio/Video e masterizzazione Risposte: 16 |
Visitano il forum: Gianca532011, Marius44 e 16 ospiti