Discussion Locked

Contents of excel file

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I am trying to print a list of the contnents from an excel file without using print screen. Is there anything I can do ??

6 replies

by awilliams3

You can utilize VBA code to 'dump' all the document properties.

I hope this may help, your request is somewhat unclear?

Sub dumpproperties()
Dim docItem As Office.DocumentProperty
Dim wbkResults As Excel.Workbook
Dim wshtResultsAs Excel.Worksheet
Dim rngItem As Excel.Range
Dim lngCount As Long
Dim varPropertyValue As Variant

On Error Resume Next
Set rngItem = Application.InputBox(prompt:="Select a cell...", _
Title:="PropertyFinder...", _
Type:=8)
On Error GoTo 0

If rngItem Is Nothing Then
Exit Sub
End If

Set wbkResults = Application.Workbooks.Add
Set wshtResults = wbkResults.Worksheets(1)
wshtResults.Cells(1, 1).EntireColumn.Font.Bold = True
wshtResults.Cells(1, 1).Value = "Properties for:"
wshtResults.Cells(1, 2).Value = rngItem.Parent.Parent.Name

lngCount = 2

For Each docItem In rngItem.Parent.Parent.BuiltinDocumentProperties
varPropertyValue = ""

On Error Resume Next
varPropertyValue = docItem.Value
On Error GoTo 0

If Not varPropertyValue = "" Then
wshtResults.Cells(lngCount, 1).Value = docItem.Name
wshtResults.Cells(lngCount, 2).Value = varPropertyValue

lngCount = lngCount + 1
End If
Next docItem

For Each docItem In ThisWorkbook.CustomDocumentProperties
wshtResults.Cells(lngCount, 1).Value = docItem.Name
wshtResults.Cells(lngCount, 2).Value = docItem.Value

lngCount = lngCount + 1
Next docItem

wshtResults.Cells.EntireColumn.AutoFit

Set rngItem = Nothing
Set docItem = Nothing
Set wbkResults = Nothing
Set wshtResults = Nothing
End Sub

This discussion is closed to new replies.