G
GerryK
Hi,
From this morning's answer to workbook open counter:
Option Explicit
Private SubWorkbook_Open()
Dim wkb As Excel.Workbook, dpsCount As
Office.DocumentProperties, dpCount As
Office.DocumentProperty
Setwkb = Me
'get the list of custom properties
Set dpsCount = wkb.CustomDocumentProperties
'get the count of times it has been opened
On Error GoTo AddProp
Set dpCount = dpsCount.Item("penCount")
On Error GoTo 0
If dpCount Is Nothing Then
End If
dpCount.Value = Int(dpCount.Value) + 1
wkb.Save 'preserve this new count
Exit Sub
AddProp:
If Err.Number = 5 Then Set dpCount = dpsCount.Add
("OpenCount", False, msoPropertyTypeNumber, 0)
Resume Next
End If
Err.Raise Err.Number, Err.Source, Err.Description,
Err.HelpFile, Err.HelpContext
End Sub
the Me comes up as a highlighted compile error and I
cannot get a count in Properties... Custom
I have this code in modules.
Please help!
TIA
From this morning's answer to workbook open counter:
Option Explicit
Private SubWorkbook_Open()
Dim wkb As Excel.Workbook, dpsCount As
Office.DocumentProperties, dpCount As
Office.DocumentProperty
Setwkb = Me
'get the list of custom properties
Set dpsCount = wkb.CustomDocumentProperties
'get the count of times it has been opened
On Error GoTo AddProp
Set dpCount = dpsCount.Item("penCount")
On Error GoTo 0
If dpCount Is Nothing Then
End If
dpCount.Value = Int(dpCount.Value) + 1
wkb.Save 'preserve this new count
Exit Sub
AddProp:
If Err.Number = 5 Then Set dpCount = dpsCount.Add
("OpenCount", False, msoPropertyTypeNumber, 0)
Resume Next
End If
Err.Raise Err.Number, Err.Source, Err.Description,
Err.HelpFile, Err.HelpContext
End Sub
the Me comes up as a highlighted compile error and I
cannot get a count in Properties... Custom
I have this code in modules.
Please help!
TIA