Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
chrisan
 
Posts: n/a
Default XL Workbook Properties

How can I print the Properties of an XL workbook as I can in Word?
  #2   Report Post  
Mark Hone
 
Posts: n/a
Default

Hi Chrisan,

I have this code in my Personal macro workbook that prints out the built-in
document properties for an Excel worksbook. It is based on an example in the
Excel help file:

Public Sub ListDocumentProperties()
On Error GoTo err_Handler

Dim xlWs As Excel.Worksheet
Dim p As Office.DocumentProperty
Dim rw As Long

rw = 2
Set xlWs = Worksheets.Add
xlWs.Name = "_Properties"
xlWs.Cells(1, 1).Value = "Property"
xlWs.Cells(1, 2).Value = "Value"
xlWs.Rows(1).EntireRow.Font.Bold = True

For Each p In ActiveWorkbook.BuiltinDocumentProperties
xlWs.Cells(rw, 1).Value = p.Name
xlWs.Cells(rw, 2).Value = p.Value
rw = rw + 1
Next p

xlWs.Columns("A:B").AutoFit
xlWs.Select
xlWs.PrintPreview

Application.DisplayAlerts = False
xlWs.Delete
Application.DisplayAlerts = True

Set p = Nothing
Set xlWs = Nothing
Exit Sub

err_Handler:
Select Case Err.Number
Case 1004 ' Sheet with same name already exists = delete it!
Application.DisplayAlerts = False
Application.ActiveWorkbook.Worksheets("_Properties ").Delete
Application.DisplayAlerts = True
Resume
Case -2147467259 ' Property value is unset = ignore and continue
Resume Next
Case Else
MsgBox Err.Number & vbCr & Err.Description
Debug.Assert 1 = 2
Resume
End Select
End Sub

NB if you have a worksheet called "_Properties" already in your workbook it
will be deleted!

Hope this helps.

Cheers,

Mark

"chrisan" wrote:

How can I print the Properties of an XL workbook as I can in Word?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HOW DO I SUM TWO CELLS FROM ONE WORKBOOK TO ANOTHER WORKBOOK? Bill O'Neal Excel Worksheet Functions 8 August 14th 09 11:36 PM
Workbook Properties KC8DCN Excel Discussion (Misc queries) 1 June 8th 05 06:34 PM
Can I display the file properties of a workbook in a custom headi. Sings4Fun Excel Worksheet Functions 2 April 16th 05 05:24 PM
Unprotect Workbook Kent Excel Discussion (Misc queries) 1 February 4th 05 01:07 AM
Stubborn toolbars in Excel 007 Excel Discussion (Misc queries) 9 December 11th 04 02:02 PM


All times are GMT +1. The time now is 12:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"