Option Explicit _____________________________________________________________________________________ Private Sub CollectCSSFiles() ' is button in on SiteAnalysis sheet Dim i As Integer, j As Integer, TLen As Integer Dim H As String, TopPath As String Dim D, FileBodies, FileNames, Files, t As Variant TopPath = GetTopPath If Range("CSSSave").Value = "" Then Range("CSSSave").Select MsgBox "Save Filename input required.", vbCritical, "Needs Input" Exit Sub End If Application.StatusBar = "Looking for the CSS Files..." Files = ListFiles(TopPath, "css", True) ' loop for files to collect For i = 0 To UBound(Files) ' we have an exclusion list For j = 1 To Range("CSSExclusions").Rows.Count H = Range("CSSExclusions").Cells(j, 1).Value If InStr(Files(i), H) > 0 And H <> "" Then GoTo NextFile Next j D = Array(ReadInFile(Files(i))) If i <> 0 Then For j = 0 To UBound(FileBodies) If FileBodies(j) = D(0) Then FileNames(j) = FileNames(j) & vbCrLf & Files(i) GoTo NextFile End If Next j End If ' first time FileNames = AppendVectors(FileNames, Files(i)) FileBodies = AppendVectors(FileBodies, D) NextFile: Next i ' loop for files to format page If IsEmpty(FileNames) Then MsgBox "No CSS files found.", vbCritical, "No files!" Else Application.StatusBar = "Processing..." For i = 0 To UBound(FileNames) ' if there are carriage returns, then we need to find the longest line If InStr(FileNames(i), vbCrLf) > 0 Then TLen = 0 t = Split(FileNames(i), vbCrLf) For j = 0 To UBound(t) If TLen < Len(t(j)) Then TLen = Len(t(j)) Next j Else TLen = Len(FileNames(i)) End If H = H & RepeatChar("-", TLen) & vbCrLf H = H & FileNames(i) & vbCrLf H = H & RepeatChar("-", TLen) & vbCrLf H = H & FileBodies(i) & vbCrLf Next i SaveIfChanged Range("CSSSave").Value, H End If Application.StatusBar = False End Sub _____________________________________________________________________________________ Private Function GetTopPath() As String GetTopPath = Range("CSSPath").Value If GetTopPath = "" Then Range("CSSFiles").Select MsgBox "Top Path input required.", vbCritical, "Needs Input" End ElseIf Not FolderExists(GetTopPath) Then Range("CSSFiles").Select MsgBox "Top Path is not a valid folder.", vbCritical, "Invalid Input" End End If End Function _____________________________________________________________________________________ Private Function RepeatChar(Char As String, Cnt As Integer) As String Dim i As Integer Dim res As String For i = 1 To Cnt res = res & Char Next i RepeatChar = res End Function _____________________________________________________________________________________ Private Sub OpenCSSFile() ' is button in on SiteAnalysis sheet ' calls Notepad If Range("CSSSave").Value = "" Then Range("CSSSave").Select MsgBox "Path and filename input required.", vbCritical, "Needs Input" Exit Sub ElseIf Not FileExists(Range("CSSSave").Value) Then Range("CSSSave").Select MsgBox "File not found.", vbCritical, "Invalid File Name" Exit Sub End If CallNotepad Range("CSSSave").Value End Sub _____________________________________________________________________________________ Private Sub CSSFileUsage() ' is button in on SiteAnalysis sheet ' returns where all the CSS files are located, by CSS file name Dim i As Integer, j As Integer, k As Integer, Row As Integer Dim H As String, TopPath As String Dim Files, Members, Names, Paths, Uniques As Variant TopPath = GetTopPath Application.StatusBar = "Looking for the CSS Files..." Files = ListFiles(TopPath, "css", True) Application.StatusBar = "Processing..." ReDim Names(UBound(Files)) ReDim Paths(UBound(Files)) ' first we split For i = 0 To UBound(Files) Names(i) = ExtractFilename(Files(i)) Paths(i) = ExtractPath(Files(i)) Next i ' get unique names Uniques = GradeUp(RemDupSameOrder(Names), , True) ' print Row = Range("OutputUL").Row With Sheets("SiteAnalysis") ' outer loop is unique names For i = 0 To UBound(Uniques) ReDim Members(10000) k = 0 ' for each Unique we first collect its members, so we can sort them For j = 0 To UBound(Paths) If Names(j) = Uniques(i) Then Members(k) = Paths(j) k = k + 1 End If Next j ReDim Preserve Members(k - 1) Members = GradeUp(Members, , True) ' print .Cells(Row, 1).Value = Uniques(i) Row = Row + 1 For k = 0 To UBound(Members) .Cells(Row, 3).Value = Members(k) Row = Row + 1 Next k Next i End With Application.StatusBar = False End Sub _____________________________________________________________________________________ Private Sub FindUnusedImages() ' is button in on SiteAnalysis sheet Dim FilterF As Boolean, FilterFF As Boolean, RecursiveFlag As Boolean Dim i As Integer, k As Integer, Row As Integer Dim FileList As New Collection Dim fls As Object Dim Code As String, Ext As String, Path As String Dim f, HtmList, Paths As Variant Path = Range("SiteAnalPath").Value RecursiveFlag = Range("SiteAnalRecurFlag").Value FilterF = Range("FilterF").Value FilterFF = Range("FilterFF").Value Row = Range("OutputUL").Row If Path = "" Then Range("SiteAnalPath").Select MsgBox "Must enter path to folder to analyze.", vbCritical, "No Path!" Exit Sub ElseIf Not FolderExists(Path) Then Range("SiteAnalPath").Select MsgBox "Path to folder does not exist.", vbCritical, "Invalid Path!" Exit Sub End If ClearSiteAnalysis If RecursiveFlag Then Paths = FindPaths(Path) Else Paths = Array(Path) End If ' ~~ loop for folders For k = 0 To UBound(Paths) Path = Paths(k) ' we do this here, to be more efficient HtmList = ListFiles(Path, "htm", , True) If IsEmpty(HtmList) Then GoTo NextFolder ' find all image files in this folder Application.StatusBar = "Getting image filenames for " & ExtractFilename(Path) & "..." Set FileList = Nothing Set fls = CreateObject("Scripting.FileSystemObject").GetFolder(Path).Files For Each f In fls Ext = UCase(Right(f, 4)) If Ext = ".JPG" Or Ext = ".GIF" Or Ext = ".PNG" Or Ext = ".ICO" Or Ext = ".TIF" Or Ext = ".BMP" Or Ext = ".PDF" Then FileList.Add ExtractFilename(f) End If Next f ' and find all image files in any images/ folder If FileExists(Path & "\images") Then Set fls = CreateObject("Scripting.FileSystemObject").GetFolder(Path & "\images").Files For Each f In fls Ext = UCase(Right(f, 4)) If Ext = ".JPG" Or Ext = ".GIF" Or Ext = ".PNG" Or Ext = ".ICO" Or Ext = ".TIF" Or Ext = ".PDF" Then If Not (Ext = ".GIF" And InStr(ExtractFilename(f), "arrow") > 0) Then FileList.Add "images/" & ExtractFilename(f) End If End If Next f End If ' get code from all HTML files Application.StatusBar = "Getting HTML code for " & ExtractFilename(Path) & "..." For Each f In HtmList Code = Code & ReadInFile(CStr(f)) Next f ' adjust ampersands Code = Replace(Code, "&", "&") ' loop for images in folder Application.ScreenUpdating = False Application.StatusBar = "Checking..." With Sheets("SiteAnalysis") For i = 1 To FileList.Count If Not ((FilterF And Right(FileList.Item(i), 6) = "-f.jpg") Or (FilterFF And Right(FileList.Item(i), 7) = "-ff.jpg")) Then If 0 = InStr(Code, """" & FileList.Item(i) & """") Then .Cells(Row, 1).Value = FileList.Item(i) If RecursiveFlag Then .Cells(Row, 4).Value = Path End If Row = Row + 1 End If End If Next i End With NextFolder: Next k Application.StatusBar = False End Sub _____________________________________________________________________________________ Private Sub FindOpenAmpersands() ' is button on SiteAnalysis sheet Dim i As Integer, j As Integer, Row As Integer, StartRow As Integer Dim D As String, Ext As String, Path As String, t As String Dim Bad, Good, Files As Variant ClearSiteAnalysis ' input Path = GetPathFromSheet("SiteAnalPath", "SiteAnalysis") StartRow = Range("OutputUL").Row If Range("FindOpenAmpType").Value = 1 Then Ext = "htm" Else Ext = "txt" End If ' get all files Application.StatusBar = "Finding filenames..." Files = ListFiles(Path, Ext, Range("SiteAnalRecurFlag").Value, True) ' loop for files Row = StartRow With Sheets("SiteAnalysis") For i = 0 To UBound(Files) Application.StatusBar = "Reading: " & Files(i) & "..." D = ReadInFile(Files(i)) Bad = AllInStr(D, "&") Good = AllInStr(D, "&") Bad = Without(Bad, Good) If Not IsEmpty(Bad) Then For j = 0 To UBound(Bad) t = Left(DropStr(D, Bad(j)), 7) If 0 = InStr(t, ";") Then .Cells(Row, 1).Value = "Bad:" .Cells(Row, 2).Value = "&" & t .Cells(Row, 3).Value = Files(i) Row = Row + 1 End If Next j End If Next i If Row > StartRow Then .Cells(StartRow, 3).Select End If .Cells(Row, 1).Value = (UBound(Files) + 1) & " " & Ext & " files checked" End With Application.StatusBar = False End Sub _____________________________________________________________________________________ Private Sub FolderHtmsStats() ' is button on AddNav and SiteAnalysis sheets ' -> analysis macro in "Extra VBA Code.txt" Dim i As Integer, j As Integer, k As Integer, Row As Integer Dim FileCount As Long Dim Bin As String, f As String, FileSuffix As String, Path As String Dim Names, res, temp As Variant ClearSiteAnalysis Row = Range("OutputUL").Row ' loop for rows on Nav page For i = 1 To Range("NavInputMatrix").Rows.Count Bin = Dec2Bin(Range("NavInputMatrix").Cells(i, 1).Value, 4) ' we only print on sheet when we build the htms If Mid(Bin, 1, 1) = "1" Then ' add to our count of files created Path = Range("NavInputMatrix").Cells(i, 2).Value ' when we getting the navigation not from the index file, we need a suffix If Right(Path, 3) = "htm" Then FileSuffix = "-" & DropStr(ExtractFilename(Path), -4) Path = DropStr(ExtractPath(Path), -1) Else FileSuffix = "" End If Names = ExtractDataNames(Path & "\FolderData" & FileSuffix & ".txt") With Sheets("SiteAnalysis") ' ~~~ when DownLevel If Mid(Bin, 2, 1) = "1" Then For j = 0 To UBound(Names) ' display Info path .Cells(Row, 1).Value = Path & "\FolderInfo-" & Names(j) & ".txt" Row = Row + 1 ' get folder info: 0-name of css files (";" delims if > 1), 1-backlinks string, 2-description (opt), ' 3-sub-indexes, 4-shortcut icon string res = ReturnFileAsArrayOfRows(Path & "\FolderInfo-" & Names(j) & ".txt") ReDim Preserve res(4) ' list CSS info in Info file If 0 < InStr(res(0), ";") Then temp = Split(res(0), ";") Else temp = Array(res(0)) End If For k = 0 To UBound(temp) .Cells(Row, 1).Value = MergePathAndFileName(Path, temp(k)) Row = Row + 1 Next k ' back links .Cells(Row, 1).Value = res(1) Row = Row + 1 ' display sub-indexes -> not implemented ' display shortcut icon If res(4) <> "" Then .Cells(Row, 1).Value = "Shortcut:" .Cells(Row, 2).Value = res(4) Row = Row + 1 End If ' display Data path f = Path & "\FolderData-" & Names(j) & ".txt" .Cells(Row, 1).Value = f FileCount = FileCount + UBound(ExtractDataNames(f)) Row = Row + 1 ' we look for notes f = ReadInFile(f) f = Left(f, InStr(f, "----") - 1) If 0 < Len(f) Then res = Split(DropStr(f, -4), vbCrLf) .Cells(Row, 1).Value = "Notes:" For k = 0 To UBound(res) .Cells(Row, 2).Value = res(k) Row = Row + 1 Next k End If ' display CSS path f = Path & "\FolderCSS-" & Names(j) & ".txt" If FileExists(f) Then .Cells(Row, 1).Value = f Row = Row + 1 End If Next j Else ' ~~~ normal processing FileCount = FileCount + UBound(Names) ' display Info path .Cells(Row, 1).Value = Path & "\FolderInfo" & FileSuffix & ".txt" Row = Row + 1 ' get folder info res = ReturnFileAsArrayOfRows(Path & "\FolderInfo" & FileSuffix & ".txt") ReDim Preserve res(4) ' list CSS info in Info file If 0 < InStr(res(0), ";") Then temp = Split(res(0), ";") Else temp = Array(res(0)) End If For k = 0 To UBound(temp) .Cells(Row, 1).Value = MergePathAndFileName(Path, temp(k)) Row = Row + 1 Next k ' back links .Cells(Row, 1).Value = res(1) Row = Row + 1 ' display description If res(2) <> "" Then .Cells(Row, 1).Value = "Descrip.:" .Cells(Row, 2).Value = res(2) Row = Row + 1 End If ' display sub-indexes If res(3) <> "" Then .Cells(Row, 1).Value = "Sub-index:" .Cells(Row, 2).Value = res(3) Row = Row + 1 End If ' display shortcut icon If res(4) <> "" Then .Cells(Row, 1).Value = "Shortcut:" .Cells(Row, 2).Value = res(4) Row = Row + 1 End If ' display Data path f = Path & "\FolderData" & FileSuffix & ".txt" .Cells(Row, 1).Value = f Row = Row + 1 ' we look for notes f = ReadInFile(f) f = Left(f, InStr(f, "----") - 1) If 0 < Len(f) Then res = Split(DropStr(f, -4), vbCrLf) .Cells(Row, 1).Value = "Notes:" For k = 0 To UBound(res) .Cells(Row, 2).Value = res(k) Row = Row + 1 Next k End If ' display CSS path f = Path & "\FolderCSS" & FileSuffix & ".txt" If FileExists(f) Then .Cells(Row, 1).Value = f Row = Row + 1 End If ' display Desc path --> not implemented when DownLevel f = Path & "\FolderDesc" & FileSuffix & ".txt" If FileExists(f) Then .Cells(Row, 1).Value = f Row = Row + 1 End If ' display TopLinks path --> not implemented when DownLevel f = Path & "\FolderTopLinks" & FileSuffix & ".txt" If FileExists(f) Then .Cells(Row, 1).Value = f Row = Row + 1 End If End If Row = Row + 1 End With End If Next i Sheets("SiteAnalysis").Cells(Row, 1).Value = "Total htm files created: " & FileCount End Sub _____________________________________________________________________________________ Private Sub SlideShowStats() ' is button on SlideShows and SiteAnalysis sheets Dim i As Integer, j As Integer, Row As Integer Dim Paths() As String Dim res, Size As Variant ClearSiteAnalysis Row = Range("OutputUL").Row ReDim Paths(Range("SSInputMatrix").Rows.Count - 1) For i = 0 To UBound(Paths) Paths(i) = Range("SSInputMatrix").Cells(i + 1, 5).Value Next i ' Application.ScreenUpdating = False With Sheets("SiteAnalysis") .Cells(Row, 1).Value = "Page" .Cells(Row, 2).Value = "Thumb" .Cells(Row, 3).Value = "Thumbs" .Cells(Row, 4).Value = "Image" .Cells(Row, 5).Value = "Average" .Cells(Row, 6).Value = "Folder" Row = Row + 1 .Cells(Row, 1).Value = "Count" .Cells(Row, 2).Value = "Size" .Cells(Row, 3).Value = "Total KB" .Cells(Row, 4).Value = "Size" .Cells(Row, 5).Value = "Image KB" .Cells(Row, 6).Value = "Path" Row = Row + 1 ' set a freeze frame Cells(Row, 1).Select ActiveWindow.FreezePanes = True ' ~~ loop for entries on SlideShows sheet For i = 0 To UBound(Paths) If Paths(i) <> "" Then If Not FileExists(Paths(i)) Then .Cells(Row, 1).Value = "Path not found:" Else If FileExists(Paths(i) & "\images") Then Paths(i) = Paths(i) & "\images" End If Application.StatusBar = "Processing: " & Paths(i) & "..." ' count res = SelectJpgs(Paths(i), "tp", True) If IsEmpty(res) Then res = SelectJpgs(Paths(i), "-tn", True) End If .Cells(Row, 1).Value = UBound(res) + 1 ' --> but we can't get size of webp files If Right(res(2), 4) = "webp" Then .Cells(Row, 2).Value = "No size info for webp files" GoTo SkipRow End If ' thumbnail pixel size (take second to skip cover) Size = GetImageSize(res(2)) If Size(0) > Size(1) Then .Cells(Row, 2).Value = Size(0) Else .Cells(Row, 2).Value = Size(1) End If ' total size of thumbnails Size = 0 For j = 0 To UBound(res) Size = Size + FileLen(res(j)) Next j .Cells(Row, 3).Value = Format(Size / 1024, "#,##0") ' image pixel size res = SelectJpgs(Paths(i), "wp", True) If IsEmpty(res) Then res = SelectJpgs(Paths(i), "-", True) End If Size = GetImageSize(res(2)) .Cells(Row, 4).Value = Size(0) & "x" & Size(1) ' avg image KB size Size = 0 For j = 0 To UBound(res) Size = Size + FileLen(res(j)) Next j Size = Size / (UBound(res) + 1) .Cells(Row, 5).Value = Round(Size / 1024, 0) SkipRow: End If ' path .Cells(Row, 6).Value = Paths(i) Row = Row + 1 End If Next i End With Application.StatusBar = False End Sub _____________________________________________________________________________________ Private Sub SlideShowOptionUsage() ' is button on SlideShows and SiteAnalysis sheets Dim i As Integer, k As Integer, Row As Integer Dim Path As String Dim Hits, NameList, res As Variant ClearSiteAnalysis Row = Range("OutputUL").Row NameList = Array("Captions", "Heading", "Subheadings", "NextFolder") ReDim Hits(3) ReDim Paths(Range("SSInputMatrix").Rows.Count - 1) For i = 0 To UBound(Paths) Path = Range("SSInputMatrix").Cells(i + 1, 5).Value ' we test for all option files in that folder For k = 0 To 2 If FileExists(Path & "\" & NameList(k) & ".txt") Then Hits(k) = Hits(k) & Path & " " End If Next k Next i ' loop by option files to post to sheet With Sheets("SiteAnalysis") For k = 0 To 2 .Cells(Row, 1).Value = NameList(k) & ".txt" Row = Row + 1 res = Split(Hits(k)) For i = 0 To UBound(res) If 0 < Len(res(i)) Then .Cells(Row, 3).Value = res(i) & "\" & NameList(k) & ".txt" End If Row = Row + 1 Next i Next k End With Application.StatusBar = False End Sub _____________________________________________________________________________________ Sub CheckAIRows() ' finds how many rows there are in each ai_ file ' also reports on ai_ files that are not on Pics sheet Dim Ct() As Integer, HitCtr(2) As Integer, Finds() As Integer, i As Integer, j As Integer, Row As Integer Dim PD As String Dim Files, LooseGroups, Orphans As Variant Row = Range("OutputUL").Row Files = ListFiles(PicDataPath, "txt", , True) ClearSiteAnalysis ' reduce to ai_'s For i = 0 To UBound(Files) If Left(ExtractFilename(Files(i)), 3) <> "ai_" Then Files(i) = Empty End If Next i Files = RemoveEmptiesInVector(Files) ReDim Ct(UBound(Files)) ReDim Finds(UBound(Files)) ' ~~ loop through remaining files For i = 0 To UBound(Files) Ct(i) = CountInString(ReadInFile(Files(i)), vbCrLf) ' filename is no longer needed, so we convert to Pic Directory PD = DropStr(DropStr(ExtractFilename(Files(i)), -4), 3) Files(i) = PD ' is file listed on Pics sheet? For j = 1 To Range("PicInputMatrix").Rows.Count If PD = Range("PicInputMatrix").Cells(j, 4).Value Then Finds(i) = 1 HitCtr(1) = HitCtr(1) + 1 End If Next j ' if not, then maybe is Group If Finds(i) <> 1 Then For j = 1 To Range("CatMat").Rows.Count If PD = Range("CatMat").Cells(j, 2).Value Then Finds(i) = 2 HitCtr(2) = HitCtr(2) + 1 End If Next j End If Next i HitCtr(0) = UBound(Files) + 1 - (HitCtr(1) + HitCtr(2)) ' ~~ we look for Groups without ai_ files ReDim LooseGroups(Range("CatMat").Rows.Count - 1) For i = 1 To Range("CatMat").Rows.Count LooseGroups(i - 1) = Range("CatMat").Cells(i, 2).Value Next i LooseGroups = RemoveEmptiesInVector(LooseGroups) For i = 0 To UBound(LooseGroups) For j = 0 To UBound(Files) If Files(j) = LooseGroups(i) Then LooseGroups(i) = Empty End If Next j Next i LooseGroups = RemoveEmptiesInVector(LooseGroups) ' ~~ report findings With Sheets("SiteAnalysis") .Cells(Row, 1).Value = "Listed?" .Cells(Row, 2).Value = "Rows" .Cells(Row, 3).Value = "Date" .Cells(Row, 4).Value = "Name" Row = Row + 1 ' set a freeze frame Cells(Row, 1).Select ActiveWindow.FreezePanes = True For i = 0 To UBound(Files) If Finds(i) = 0 Then .Cells(Row, 1).Value = "No" ElseIf Finds(i) = 2 Then .Cells(Row, 1).Value = "Group" End If .Cells(Row, 2).Value = Ct(i) .Cells(Row, 3).Value = "'" & GetAI(Files(i), 4, True) .Cells(Row, 4).Value = "ai_" & Files(i) & ".txt" Row = Row + 1 Next i .Cells(Row, 1).Value = UBound(Files) + 1 & " total files found: Albums: " & HitCtr(1) & ", Groups: " & HitCtr(2) & ", Orphans: " & HitCtr(0) Row = Row + 1 If Not IsEmpty(LooseGroups) Then .Cells(Row, 1).Value = "Groups without ai_ files (The Major Categories):" Row = Row + 1 For i = 0 To UBound(LooseGroups) .Cells(Row, 2).Value = LooseGroups(i) Row = Row + 1 Next i End If End With End Sub _____________________________________________________________________________________ Sub PicAlbumStats(Optional ForagOnly As Boolean) ' is button on SiteAnalysis sheet, and is called by Foraging Dashboard Dim i As Integer, j As Integer, k As Integer, Row As Integer Dim Ctr(9) As Long Dim P As String, Path As String, PicD As String, t As String Dim FileList, Size As Variant Row = Range("OutputUL").Row ClearSiteAnalysis Application.ScreenUpdating = False Application.Calculation = xlCalculationManual With Sheets("SiteAnalysis") ' heading .Cells(Row, 1).Value = "Web-Size" .Cells(Row, 2).Value = "Web-Size" .Cells(Row, 3).Value = "Original" .Cells(Row, 4).Value = "Original" .Cells(Row, 6).Value = "Picture" .Cells(Row, 7).Value = "Max pd_" Row = Row + 1 .Cells(Row, 1).Value = "Average" .Cells(Row, 2).Value = "Max" .Cells(Row, 3).Value = "Average" .Cells(Row, 4).Value = "Max" .Cells(Row, 5).Value = "Date" .Cells(Row, 6).Value = "Count" .Cells(Row, 7).Value = "Length" .Cells(Row, 8).Value = "Album" Row = Row + 1 ' set a freeze frame Cells(Row, 1).Select ActiveWindow.FreezePanes = True ' loop for albums on Pics sheet (but not virtual ones) For i = 1 To Range("PicInputMatrix").Rows.Count PicD = Range("PicInputMatrix").Cells(i, 4).Value If PicD <> "" And Left(GetFromPicMat(PicD, 3), 1) <> "v" And ("F-" = Left(PicD, 2) Or Not ForagOnly) Then DoEvents Application.StatusBar = "Getting " & PicD & "..." For j = 0 To 9 Ctr(j) = 0 Next j P = PicPath(PicD) & PicD FileList = PicsInAlbum(P) If IsEmpty(FileList) Then .Cells(Row, 1).Value = "No JPGs found" GoTo SkipOver End If For j = 0 To UBound(FileList) t = P & "\w" & FileList(j) ' in the early days there were no web-size. only original-size If FileExists(t) Then Size = GetImageSize(t) If Size(0) <> 0 Then ' web-size find (1) average widths and (2) heights Ctr(1) = Ctr(1) + Size(0) Ctr(2) = Ctr(2) + Size(1) Ctr(0) = Ctr(0) + 1 ' web-size find (3) maxiumum widths and (4) heights If Size(0) > Ctr(3) Then Ctr(3) = Size(0) If Size(1) > Ctr(4) Then Ctr(4) = Size(1) End If End If ' find (5) average widths and (6) heights Size = GetImageSize(P & "\" & FileList(j)) Ctr(5) = Ctr(5) + Size(0) Ctr(6) = Ctr(6) + Size(1) ' find (7) maxiumum widths and (8) heights If Size(0) > Ctr(7) Then Ctr(7) = Size(0) If Size(1) > Ctr(8) Then Ctr(8) = Size(1) Next j ' convert averages ' j = UBound(FileList) + 1 If Ctr(0) <> 0 Then Ctr(1) = Round(Ctr(1) / Ctr(0), 0) Ctr(2) = Round(Ctr(2) / Ctr(0), 0) End If Ctr(5) = Round(Ctr(5) / j, 0) Ctr(6) = Round(Ctr(6) / j, 0) ' ~~ print row If Ctr(0) <> 0 Then ' (1) web-size find average widths and heights .Cells(Row, 1).Value = Ctr(1) & "x" & Ctr(2) ' (2) web-size find maxiumum widths and heights .Cells(Row, 2).Value = Ctr(3) & "x" & Ctr(4) End If ' (3) find average widths and heights .Cells(Row, 3).Value = Ctr(5) & "x" & Ctr(6) ' (4) find maxiumum widths and heights .Cells(Row, 4).Value = Ctr(7) & "x" & Ctr(8) ' (5) date ' .Cells(Row, 5).Value = "'" & GetAI(PicD, 4, True) ' (6) Count .Cells(Row, 6).Value = UBound(FileList) + 1 ' (7) Max caption length (to see whether we can switch index to inline-block) Size = GetPicData(PicD, "pd") For j = 0 To UBound(Size) k = Len(RemoveHTML(Size(j))) If k > Ctr(9) Then Ctr(9) = k Next j .Cells(Row, 7).Value = Ctr(9) ' (8) PicD SkipOver: .Cells(Row, 8).Value = PicD Row = Row + 1 End If Next i End With Application.StatusBar = False Application.Calculation = xlCalculationAutomatic End Sub _____________________________________________________________________________________ Private Sub FindUnusedData() ' is button on SiteAnalysis sheet Dim i As Integer, j As Integer, n As Integer, Row As Integer, TotJpgs As Integer Dim S As String, SkipList() As String Dim AlbumNames, Exts, Files, FolderList, res As Variant n = Range("PicInputMatrix").Rows.Count ReDim AlbumNames(n) ClearSiteAnalysis Application.ScreenUpdating = False Application.Calculation = xlCalculationManual Row = Range("OutputUL").Row ' get vector of album names from Pics sheet for all portfolios For i = 1 To n AlbumNames(i) = Range("PicInputMatrix").Cells(i, 4).Value Next i AlbumNames = RemoveEmptiesInVector(AlbumNames) ' folders we skip SkipList = Split("data icons images") ' -> now only doing first portfolio '' ~~ loop for portfolios '' check that we haven't already done this portfolio ' get all folders in portfolio folder FolderList = FoldersIn(PicPath, True) TotJpgs = 0 With Sheets("SiteAnalysis") ' loop for folders For i = 0 To UBound(FolderList) If Not IsMember(AlbumNames, FolderList(i)) And Not IsMember(SkipList, FolderList(i)) Then .Cells(Row, 1).Value = "Extra folder found:" .Cells(Row, 3).Value = PicPath & FolderList(i) Row = Row + 1 ' find unique file extensions in folder Files = ListFiles(PicPath & FolderList(i), "*") If IsEmpty(Files) Then .Cells(Row, 2).Value = "No files" Row = Row + 1 Else Exts = ReturnUniqueFolderExts(Files) ' loop for extensions For j = 0 To UBound(Exts) res = ListFiles(PicPath & FolderList(i), Exts(j)) If Exts(j) = "JPG" Then TotJpgs = TotJpgs + UBound(res) + 1 End If S = "s" If UBound(res) = 0 Then S = "" .Cells(Row, 2).Value = UBound(res) + 1 & " " & Exts(j) & " file" & S Row = Row + 1 Next j End If ' check for sub-folders res = FoldersIn(PicPath & FolderList(i)) If Not IsEmpty(res) Then .Cells(Row, 1).Value = Exts(i) & " has " & UBound(res) + 1 & " folders" Row = Row + 1 End If End If Next i Row = Row + 1 .Cells(Row, 1).Value = "Total JPGs = " & TotJpgs End With Application.Calculation = xlCalculationAutomatic End Sub _____________________________________________________________________________________ Function ReturnUniqueFolderExts(ByVal FileNames As Variant) As Variant ' given a list of all files in a folder, this will return a list of the unique file extensions ' returns empty if input is empty If IsEmpty(FileNames) Then Exit Function Dim i As Integer For i = 0 To UBound(FileNames) FileNames(i) = UCase(ExtractExtension(FileNames(i))) Next i ReturnUniqueFolderExts = RemDupSameOrder(FileNames) End Function _____________________________________________________________________________________ Sub OpenInNotepad() ' this is also called by Ctrl-R Dim FileName As String If Range("OutputUL").Value = "Web-Size" Then FileName = ReturnRowFileFolderPics(True) Else FileName = ReturnRowFileFolder(True) End If If FileExists(FileName) Then If Right(FileName, 4) = ".jpg" Or Right(FileName, 4) = ".gif" Then If FileExists(PathToIrfanView) Then Shell PathToIrfanView & " " & FileName, vbNormalFocus Else MsgBox "Before opening an image you need to install IrfanView. And then put the path to its exe file in the CallIrfanView function.", vbCritical, "Aborted!" End End If Else CallNotepad FileName End If Else MsgBox "On the cursor row, no valid file name is found.", vbCritical, "Can't Proceed!" End If End Sub _____________________________________________________________________________________ Private Sub OpenFolderOnRow() Dim FldrName As String If Range("OutputUL").Value = "Web-Size" Then FldrName = ReturnRowFileFolderPics(False) Else FldrName = ReturnRowFileFolder(False) End If If FolderExists(FldrName) Then CallExplorer FldrName Else MsgBox "On the cursor row, no valid folder name is found.", vbCritical, "Can't Proceed!" End If End Sub _____________________________________________________________________________________ Private Sub ViewWebPageOnRow() Dim Path As String If Range("OutputUL").Value = "Web-Size" Then Path = ReturnRowFileFolderPics(True) Else Path = ReturnRowFileFolder(True) End If If FileExists(Path) Then ActiveWorkbook.FollowHyperlink Path Else MsgBox "On the cursor row, no valid file name is found.", vbCritical, "Can't Proceed!" End If End Sub _____________________________________________________________________________________ Function ReturnRowFileFolderPics(FileFlag As Boolean) As String ' when pictures we know it is Column 8 Dim Row As Integer ' is cursor in the input section? Row = ActiveCell.Row If Row < Range("OutputUL").Row + 2 Then MsgBox "Your cursor is not in the Output Section.", vbCritical, "Cursor Too Far Up" End End If ReturnRowFileFolderPics = PicPath & Cells(Row, 8).Value If FileFlag Then ReturnRowFileFolderPics = ReturnRowFileFolderPics & "\index.htm" End If End Function _____________________________________________________________________________________ Function ReturnRowFileFolder(FileFlag As Boolean) As String ' returns file or folder found on active row ' FileFlag forces response to be file ' SiteAnalysis sheet must be ActiveSheet Dim j As Integer, Row As Integer Dim IndName As String Row = ActiveCell.Row ' is cursor in the input section? If Row < Range("OutputUL").Row Then MsgBox "Your cursor is not in the Output Section.", vbCritical, "Cursor Too Far Up" End End If ' loop to find if valid data For j = 1 To 8 If Mid(Cells(Row, j).Value, 2, 1) = ":" Then Exit For Next j If j < 9 Then ReturnRowFileFolder = Cells(Row, j).Value If FileFlag Then ' does it need an index file? If InStr(Right(ReturnRowFileFolder, 6), ".") = 0 Then ' it won't be in images subfolder If Right(ReturnRowFileFolder, 6) = "images" Then ReturnRowFileFolder = DropStr(ReturnRowFileFolder, -7) End If IndName = GetIndexFileName(ReturnRowFileFolder) ' check if index file exists within the folder If Len(IndName) = 0 Then MsgBox "No index file found in folder:" & vbLf & ReturnRowFileFolder, vbCritical, "Aborted!" End End If ReturnRowFileFolder = ReturnRowFileFolder & "\" & IndName End If Else If InStr(Right(ReturnRowFileFolder, 6), ".") > 0 Then ReturnRowFileFolder = ExtractPath(ReturnRowFileFolder) End If End If ElseIf FileFlag Then ' loop to see if file name without a path For j = 1 To 8 If InStr(Right(Cells(Row, j).Value, 6), ".") > 0 Then If Left(Cells(Row, j).Value, 3) = "ai_" Then ReturnRowFileFolder = PicDataPath & Cells(Row, j).Value Else ReturnRowFileFolder = Range("SiteAnalPath").Value & "\" & Cells(Row, j).Value Exit Function End If End If Next j End If End Function _____________________________________________________________________________________ Sub ClearSiteAnalysis() ' is button on SiteAnalysis sheet. and called by many macros Application.ScreenUpdating = False Sheets("SiteAnalysis").Select Range("SiteAnalPath").Select Range("A" & Range("OutputUL").Row & ":J65536").Clear Application.Goto Range("A1"), True Range("OutputUL").Select ActiveWindow.FreezePanes = False Application.ScreenUpdating = True Application.ScreenUpdating = False End Sub _____________________________________________________________________________________ Private Sub GoToBuildersFromAnalysis() ClearSiteAnalysis Sheets("Dashboard").Select End Sub _____________________________________________________________________________________