wb Counter woes

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top