bionlazy.blogg.se

Vba to read file details
Vba to read file details











vba to read file details
  1. #VBA TO READ FILE DETAILS HOW TO#
  2. #VBA TO READ FILE DETAILS CODE#
  3. #VBA TO READ FILE DETAILS WINDOWS#

It is possible to catch the errors so that you know the value is blank: 'Catching errors when there is no value Dim fileProperty As Variant Referencing a property which does not have any information will throw and error. But that is outside the scope of this post. Note: Take a look in the comments section below as there appears to be a way to read and change properties on a closed file. Set Wb = Workbooks.Open("C:\Users\marks\Documents\myFileTest.xlsx")ĭebug.Print Wb.BuiltinDocumentProperties("Last save time") 'Find the Last saved time of a currently closed file Dim Wb As Workbook Therefore it is necessary to open the file, read the properties, then close the file. 'Finding the creation date of another workbook Dim Wb As Workbookĭebug.Print Wb.BuiltinDocumentProperties("Creation date") Working with closed filesīy using the BuiltinDocumentProperties there is no way to read the properties from a closed file.

#VBA TO READ FILE DETAILS CODE#

The basic VBA code 'Finding the author of the ActiveWorkbook Debug.Print ActiveWorkbook.BuiltinDocumentProperties("Author") Yet, both Excel and PowerPoint files have a number of slides property, it’s just not used in all circumstances. For example, Excel files do not have data about the number of slides property, but a PowerPoint file does. Not all document properties are populated with data, as it depends on the file type. The good news is, we can access this information using VBA with the BuiltinDocumentProperties Property. There is useful information in here, such as author, creation date, last saved date etc. Right-click on the file and select Properties.

#VBA TO READ FILE DETAILS WINDOWS#

then all you need to do is add the attribute number into the array.In the Windows Explorer it is possible to view a document’s properties. but if you were to want to populate a heap more columns with more attributes. you can shorten this.Ĭode Sub RecursiveFolder(objFolder As Scripting.Folder, _ĭim oDir: Set oDir = oShell.Namespace(txt)Ĭells(NextRow, "A").Value = oDir.GetDetailsOf(sFile, 0)Ĭells(NextRow, "B").Value = oDir.GetDetailsOf(sFile, 1)Ĭells(NextRow, "C").Value = oDir.GetDetailsOf(sFile, 2)Ĭells(NextRow, "D").Value = oDir.GetDetailsOf(sFile, 4)Ĭells(NextRow, "E").Value = oDir.GetDetailsOf(sFile, 5)Ĭells(NextRow, "F").Value = oDir.GetDetailsOf(sFile, 18)Ĭells(NextRow, "G").Value = oDir.GetDetailsOf(sFile, 24) 'Show Filename, Attribute Name and Attribute Value in Columns B,C,DĪttribName = InputBox(Prompt:="Enter Attribute Value (0-266).")Ĭells(j, 2).Value = oDir.GetDetailsOf(sFile, 0)Ĭells(j, 3).Value = oDir.GetDetailsOf(oDir.Items, AttribName)Ĭells(j, 4).Value = oDir.GetDetailsOf(sFile, AttribName)Īlso. ' Show all known file attribute number designations.ĭim oShell: Set oShell = CreateObject("Shell.Application")ĭim oDir: Set oDir = oShell.Namespace("C:\Users\apo\Desktop\Excel Test Files")Ĭells(i + 1, 1).Value = oDir.GetDetailsOf(oDir.Items, i) & " = " & i

#VBA TO READ FILE DETAILS HOW TO#

I would greatly appreciate it if someone could show me how to do this. I have found functions that are used to pull Comments and Tags from files but haven't been able to incorporate them in to the code I already have. However, this doesn't seem to work with finding Comments, Tags, etc. I have been using it to get the Name, Size, Type, and relevant Dates associated with files in a folder. NextRow = Cells(Rows.Count, "A").End(xlUp).Row + 1Ĭells(NextRow, "D").Value = objFile.DateCreatedĬells(NextRow, "E").Value = objFile.DateLastAccessedĬells(NextRow, "F").Value = objFile.DateLastModifiedįor Each objSubFolder In objFolder.SubFolders Sub RecursiveFolder(objFolder As Scripting.Folder, _

vba to read file details

'Change the width of the columns to achieve the best fit Set objTopFolder = objFSO.GetFolder(strTopFolderName) Set objFSO = CreateObject("Scripting.FileSystemObject") 'Create an instance of the FileSystemObject StrTopFolderName = "C:\Users\josdun\Desktop\PDFs" & "\" & ActiveSheet.Name

vba to read file details

'Insert the headers for Columns A through F Code 'Force the explicit delcaration of variables













Vba to read file details