Johnny2000
New Member
- Joined
- Apr 16, 2013
- Messages
- 2
Hi,
I a newbie to VBA and not got much further than creating userforms (but totally addicted) and i am desperate for some help.
I have some code below which i need modded to search sub folders as well.
Can someone pleae help me and it is greatly appreciated. At least advise if it is possible or not.
I dont know if it needs a varible declared or how to get it to search sub folders.
i have tried subfolder = true etc..
Sub PDFPageNumbers()
Dim FSO As Object
Dim F_Folder As Object
Dim F_File As Object
Dim Selected_Items As String
Dim DialogFolder As FileDialog
Dim Acrobat_File As Acrobat.AcroPDDoc
Dim i As Long
'Select PDF Directory
Set DialogFolder = Application.FileDialog(msoFileDialogFolderPicker)
If DialogFolder.Show = -1 Then
Selected_Items = DialogFolder.SelectedItems(1)
Else: Set DialogFolder = Nothing
End If
Set DialogFolder = Nothing
Set FSO = CreateObject("Scripting.FileSystemObject")
Set F_Folder = FSO.getfolder(Selected_Items)
i = 2
Filecount = F_Folder.Files.Count
For Each F_File In F_Folder.Files
Selected_Items = UCase(F_File.Path)
If Right(Selected_Items, 4) = ".PDF" Then
Set Acrobat_File = New Acrobat.AcroPDDoc
Acrobat_File.Open Selected_Items
Cells(i, 1).Value = Selected_Items
Cells(i, 2).Value = Acrobat_File.GetNumPages
i = i + 1
Acrobat_File.Close
Set Acrobat_File = Nothing
End If
Application.StatusBar = "Completed " & Application.Text((i - 2) / Filecount, "0.00%")
Next
Application.StatusBar = False
Range("A:B").Columns.AutoFit
Set F_File = Nothing
Set F_Folder = Nothing
Set FSO = Nothing
End Sub
I a newbie to VBA and not got much further than creating userforms (but totally addicted) and i am desperate for some help.
I have some code below which i need modded to search sub folders as well.
Can someone pleae help me and it is greatly appreciated. At least advise if it is possible or not.
I dont know if it needs a varible declared or how to get it to search sub folders.
i have tried subfolder = true etc..
Sub PDFPageNumbers()
Dim FSO As Object
Dim F_Folder As Object
Dim F_File As Object
Dim Selected_Items As String
Dim DialogFolder As FileDialog
Dim Acrobat_File As Acrobat.AcroPDDoc
Dim i As Long
'Select PDF Directory
Set DialogFolder = Application.FileDialog(msoFileDialogFolderPicker)
If DialogFolder.Show = -1 Then
Selected_Items = DialogFolder.SelectedItems(1)
Else: Set DialogFolder = Nothing
End If
Set DialogFolder = Nothing
Set FSO = CreateObject("Scripting.FileSystemObject")
Set F_Folder = FSO.getfolder(Selected_Items)
i = 2
Filecount = F_Folder.Files.Count
For Each F_File In F_Folder.Files
Selected_Items = UCase(F_File.Path)
If Right(Selected_Items, 4) = ".PDF" Then
Set Acrobat_File = New Acrobat.AcroPDDoc
Acrobat_File.Open Selected_Items
Cells(i, 1).Value = Selected_Items
Cells(i, 2).Value = Acrobat_File.GetNumPages
i = i + 1
Acrobat_File.Close
Set Acrobat_File = Nothing
End If
Application.StatusBar = "Completed " & Application.Text((i - 2) / Filecount, "0.00%")
Next
Application.StatusBar = False
Range("A:B").Columns.AutoFit
Set F_File = Nothing
Set F_Folder = Nothing
Set FSO = Nothing
End Sub