Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default How do I print file properties with worksheet in excel ?

I want to print file properties when I print out a worksheet.
I can't find a setting that allows me to do this.

I can do this in word though.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,316
Default How do I print file properties with worksheet in excel ?

The following code inserts a new worksheet at the end of the current workbook
and prints the doc properties and their current values. The On Error Resume
Next is used because Excel does not have all of the built-in document
properties and and error occurs each time a property the Excel does not have
is encounterd.

As for the company and save time showing up more than once? Well I haven't
figured that one out yet.

Sub DocProps()

Dim wb As Workbook
Dim ws As Worksheet
Dim i As Integer
Dim l As Long
Dim p As DocumentProperty
Dim strProp As String
Set wb = ActiveWorkbook

On Error Resume Next

For Each ws In wb.Worksheets
i = i + 1
Next ws

wb.Worksheets.Add After:=Worksheets(i)

l = 1
Worksheets(i + 1).Activate
For Each p In ActiveWorkbook. _
BuiltinDocumentProperties
strProp = p.Name & ": " & p.Value
Cells(l, 1).Value = strProp
l = l + 1
Next

End Sub
--
Kevin Backmann


"redd" wrote:

I want to print file properties when I print out a worksheet.
I can't find a setting that allows me to do this.

I can do this in word though.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,316
Default How do I print file properties with worksheet in excel ?

Here's a cheesy work-around for repeating values:

Sub DocProps()

Dim wb As Workbook
Dim ws As Worksheet
Dim i As Integer
Dim l As Long
Dim p As DocumentProperty
Dim strProp As String
Dim intCompCount As Integer
Dim intSaveCount As Integer
Set wb = ActiveWorkbook

On Error Resume Next

For Each ws In wb.Worksheets
i = i + 1
Next ws

wb.Worksheets.Add After:=Worksheets(i)

l = 1
Worksheets(i + 1).Activate
For Each p In ActiveWorkbook. _
BuiltinDocumentProperties
strProp = p.Name
If strProp = "Last save time:" And intSaveCount = 0 Then
strProp = p.Name & ": " & p.Value
ElseIf strProp = "Company:" And intCompCount = 0 Then
strProp = p.Name & ": " & p.Value
Else
Cells(l, 1).Value = strProp
l = l + 1
End If
Next

End Sub

--
Kevin Backmann


"Kevin B" wrote:

The following code inserts a new worksheet at the end of the current workbook
and prints the doc properties and their current values. The On Error Resume
Next is used because Excel does not have all of the built-in document
properties and and error occurs each time a property the Excel does not have
is encounterd.

As for the company and save time showing up more than once? Well I haven't
figured that one out yet.

Sub DocProps()

Dim wb As Workbook
Dim ws As Worksheet
Dim i As Integer
Dim l As Long
Dim p As DocumentProperty
Dim strProp As String
Set wb = ActiveWorkbook

On Error Resume Next

For Each ws In wb.Worksheets
i = i + 1
Next ws

wb.Worksheets.Add After:=Worksheets(i)

l = 1
Worksheets(i + 1).Activate
For Each p In ActiveWorkbook. _
BuiltinDocumentProperties
strProp = p.Name & ": " & p.Value
Cells(l, 1).Value = strProp
l = l + 1
Next

End Sub
--
Kevin Backmann


"redd" wrote:

I want to print file properties when I print out a worksheet.
I can't find a setting that allows me to do this.

I can do this in word though.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,316
Default How do I print file properties with worksheet in excel ?

Please ignore the prior post with the cheesy work around, it did not work
correctly. Here's a correction that does work:

Dim wb As Workbook
Dim ws As Worksheet
Dim i As Integer
Dim l As Long
Dim p As DocumentProperty
Dim strProp As String
Dim intCompCount As Integer
Dim intSaveCount As Integer
Set wb = ActiveWorkbook

On Error Resume Next

Application.DisplayAlerts = False

For Each ws In wb.Worksheets
If ws.Name = "Doc Props" Then ws.Delete
Next ws
For Each ws In wb.Worksheets
i = i + 1
Next ws

wb.Worksheets.Add After:=Worksheets(i)
ActiveSheet.Name = "Doc Props"


l = 1
Worksheets(i + 1).Activate
For Each p In ActiveWorkbook. _
BuiltinDocumentProperties
strProp = p.Name
If strProp = "Last save time:" And intSaveCount = 0 Then
strProp = p.Name & ": " & p.Value
intSaveCount = intSaveCount + 1
ElseIf strProp = "Company:" And intCompCount = 0 Then
strProp = p.Name & ": " & p.Value
intCompCount = intCompCount + 1
Else
strProp = p.Name & ": " & p.Value
Cells(l, 1).Value = strProp
l = l + 1
End If
Next

End Sub

--
Kevin Backmann


"Kevin B" wrote:

Here's a cheesy work-around for repeating values:

Sub DocProps()

Dim wb As Workbook
Dim ws As Worksheet
Dim i As Integer
Dim l As Long
Dim p As DocumentProperty
Dim strProp As String
Dim intCompCount As Integer
Dim intSaveCount As Integer
Set wb = ActiveWorkbook

On Error Resume Next

For Each ws In wb.Worksheets
i = i + 1
Next ws

wb.Worksheets.Add After:=Worksheets(i)

l = 1
Worksheets(i + 1).Activate
For Each p In ActiveWorkbook. _
BuiltinDocumentProperties
strProp = p.Name
If strProp = "Last save time:" And intSaveCount = 0 Then
strProp = p.Name & ": " & p.Value
ElseIf strProp = "Company:" And intCompCount = 0 Then
strProp = p.Name & ": " & p.Value
Else
Cells(l, 1).Value = strProp
l = l + 1
End If
Next

End Sub

--
Kevin Backmann


"Kevin B" wrote:

The following code inserts a new worksheet at the end of the current workbook
and prints the doc properties and their current values. The On Error Resume
Next is used because Excel does not have all of the built-in document
properties and and error occurs each time a property the Excel does not have
is encounterd.

As for the company and save time showing up more than once? Well I haven't
figured that one out yet.

Sub DocProps()

Dim wb As Workbook
Dim ws As Worksheet
Dim i As Integer
Dim l As Long
Dim p As DocumentProperty
Dim strProp As String
Set wb = ActiveWorkbook

On Error Resume Next

For Each ws In wb.Worksheets
i = i + 1
Next ws

wb.Worksheets.Add After:=Worksheets(i)

l = 1
Worksheets(i + 1).Activate
For Each p In ActiveWorkbook. _
BuiltinDocumentProperties
strProp = p.Name & ": " & p.Value
Cells(l, 1).Value = strProp
l = l + 1
Next

End Sub
--
Kevin Backmann


"redd" wrote:

I want to print file properties when I print out a worksheet.
I can't find a setting that allows me to do this.

I can do this in word though.

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
importing a particular excel worksheet into another excel file dinouk Excel Worksheet Functions 0 August 10th 06 02:03 PM
Excel file with hyperlinks takes a long time to open over the network Didier P Links and Linking in Excel 3 July 4th 06 04:39 PM
Excel Outlook Attachments opening after several errors everytime cito_support Setting up and Configuration of Excel 2 March 13th 06 06:15 PM
Weekly Transaction Processing Ralph Howarth Excel Worksheet Functions 4 January 19th 05 05:37 AM
Read Text File into Excel Using VBA Willie T Excel Discussion (Misc queries) 13 January 8th 05 12:37 AM


All times are GMT +1. The time now is 12:24 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"