A
Alan Silver
Hello,
I have been writing some VBScript that uses a custom document property
to store the ID of the calendar entry in Outlook to which the document
relates.
The problem that I have is that I cannot clear the entry. I have tried
setting it to an empty string, and even deleting it completely, but next
time I open the document, the property is still there !! I can step
through the code, watch it delete the entry, try checking the entry and
get an "invalid procedure call or argument" error, but STILL see the
property next time the document is opened !!
Here is the code ...
Private Sub Document_Close()
Dim olDocProps As DocumentProperties
Dim slCalID As String
Dim flGetDate As frmGetDate
' check the properties for the calendar ID
Set olDocProps = ActiveDocument.CustomDocumentProperties
On Error Resume Next
' see if the property exists. If not, an error will be raised
slCalID = olDocProps.Item("CalItemID").Value
If Err.Number = 0 Then
' the property exists, delete it
olDocProps.Item("CalItemID").Delete
ActiveDocument.Save
End If
' so now we know there isn't a property for the ID.
' If there is already a calendar item, slCalID will be non-empty
On Error GoTo 0
' Only do the business if we are not editing the template
If Right(ActiveDocument.Name, 4) <> ".dot" Then
' editing a real document.
' do the clever Outlook bits here
End If
End Sub
Note that I snipped the clever Outlook bits as they aren't relevant.
My problem is that I don't want to save the calendar entry ID when
editing the template, so that when a new document is created from the
template, it will not have this property. That way the code knows to
create a new entry. If the ID is non-blank, the code modifies an
existing calendar entry.
I originally had the code create a property if one didn't exist, so I
could just update it hen closing the document, but that gave the same
problem. I changed it to deleting the property (as it is above) in an
attempt to get around the problem.
Whenever I open the document again and step through the code, slCalID
gets set to "00000000B694DB5BF6EA2149BA66B7D297C3EE6024AB2000", which is
(presumably) the ID of the calendar entry I was using when I tested the
code.
Please help me remove this property. It's driving me mad !!
TIA
I have been writing some VBScript that uses a custom document property
to store the ID of the calendar entry in Outlook to which the document
relates.
The problem that I have is that I cannot clear the entry. I have tried
setting it to an empty string, and even deleting it completely, but next
time I open the document, the property is still there !! I can step
through the code, watch it delete the entry, try checking the entry and
get an "invalid procedure call or argument" error, but STILL see the
property next time the document is opened !!
Here is the code ...
Private Sub Document_Close()
Dim olDocProps As DocumentProperties
Dim slCalID As String
Dim flGetDate As frmGetDate
' check the properties for the calendar ID
Set olDocProps = ActiveDocument.CustomDocumentProperties
On Error Resume Next
' see if the property exists. If not, an error will be raised
slCalID = olDocProps.Item("CalItemID").Value
If Err.Number = 0 Then
' the property exists, delete it
olDocProps.Item("CalItemID").Delete
ActiveDocument.Save
End If
' so now we know there isn't a property for the ID.
' If there is already a calendar item, slCalID will be non-empty
On Error GoTo 0
' Only do the business if we are not editing the template
If Right(ActiveDocument.Name, 4) <> ".dot" Then
' editing a real document.
' do the clever Outlook bits here
End If
End Sub
Note that I snipped the clever Outlook bits as they aren't relevant.
My problem is that I don't want to save the calendar entry ID when
editing the template, so that when a new document is created from the
template, it will not have this property. That way the code knows to
create a new entry. If the ID is non-blank, the code modifies an
existing calendar entry.
I originally had the code create a property if one didn't exist, so I
could just update it hen closing the document, but that gave the same
problem. I changed it to deleting the property (as it is above) in an
attempt to get around the problem.
Whenever I open the document again and step through the code, slCalID
gets set to "00000000B694DB5BF6EA2149BA66B7D297C3EE6024AB2000", which is
(presumably) the ID of the calendar entry I was using when I tested the
code.
Please help me remove this property. It's driving me mad !!
TIA