R
Rhino
This sub worked fine several times then suddenly stopped working. Can anyone
help me figure out what is wrong?
-----------------------------------------------------------------------------------------------------
Public Sub getLastRevisionDate()
'Set the title for the MsgBoxes which will be displayed.
Const TITLE As String = "Custom Properties"
'Set the name of the custom property.
Const REVISION_DATE_KEY As String = "LAST_REVISION_DATE"
'If there is no document open, there is nowhere to get custom properties
either. Inform the user.
If Application.Documents.count = 0 Then
MsgBox "There are no documents open so no custom properties can be
found. Open a document before trying this macro again.", vbOKOnly, "Custom
Properties"
Exit Sub
End If
'If the desired property does not exist in this document, inform the user.
'Otherwise, display the value of the desired property.
If (ActiveDocument.CustomDocumentProperties(REVISION_DATE_KEY).value =
False) Then
MsgBox "The " & REVISION_DATE_KEY & " is not defined for the Active
Document.", vbOKOnly, TITLE
Else
Dim revisionDate As String
revisionDate =
ActiveDocument.CustomDocumentProperties(REVISION_DATE_KEY).value
MsgBox "The value of the " & REVISION_DATE_KEY & " is " & revisionDate &
".", vbOKOnly, TITLE
End If
End Sub
-----------------------------------------------------------------------------------------------------
I get this error message on the second If statement, the one that is
checking the value of the LAST_REVISION_DATE property: "Run-time error '5':
Invalid procedure call or argument
For what it's worth, I tried hardcoding the name of the key in the brackets
and putting quotes around it but it made no difference at all. Also, there
is an active document open within Word.
Before the statement started crashing, it worked fine for several
iterations. Prior to that, it also failed every time but those times the
error message complained about a missing object. Then, it just started
working right about the time I was getting really really frustrated. For the
life of me, I don't know why this statement has been alternating between
working fine and not working at all: I haven't changed it in hours. There's
obviously some kind of technique or practice that I'm not following which is
causing me to fall over my own feet; I just wish I could figure out what it
is....
Anyway, if you can help me figure out what's wrong here, I'd be deeply
grateful.
This code is so close to finished it hurts. I really want to finish this.
help me figure out what is wrong?
-----------------------------------------------------------------------------------------------------
Public Sub getLastRevisionDate()
'Set the title for the MsgBoxes which will be displayed.
Const TITLE As String = "Custom Properties"
'Set the name of the custom property.
Const REVISION_DATE_KEY As String = "LAST_REVISION_DATE"
'If there is no document open, there is nowhere to get custom properties
either. Inform the user.
If Application.Documents.count = 0 Then
MsgBox "There are no documents open so no custom properties can be
found. Open a document before trying this macro again.", vbOKOnly, "Custom
Properties"
Exit Sub
End If
'If the desired property does not exist in this document, inform the user.
'Otherwise, display the value of the desired property.
If (ActiveDocument.CustomDocumentProperties(REVISION_DATE_KEY).value =
False) Then
MsgBox "The " & REVISION_DATE_KEY & " is not defined for the Active
Document.", vbOKOnly, TITLE
Else
Dim revisionDate As String
revisionDate =
ActiveDocument.CustomDocumentProperties(REVISION_DATE_KEY).value
MsgBox "The value of the " & REVISION_DATE_KEY & " is " & revisionDate &
".", vbOKOnly, TITLE
End If
End Sub
-----------------------------------------------------------------------------------------------------
I get this error message on the second If statement, the one that is
checking the value of the LAST_REVISION_DATE property: "Run-time error '5':
Invalid procedure call or argument
For what it's worth, I tried hardcoding the name of the key in the brackets
and putting quotes around it but it made no difference at all. Also, there
is an active document open within Word.
Before the statement started crashing, it worked fine for several
iterations. Prior to that, it also failed every time but those times the
error message complained about a missing object. Then, it just started
working right about the time I was getting really really frustrated. For the
life of me, I don't know why this statement has been alternating between
working fine and not working at all: I haven't changed it in hours. There's
obviously some kind of technique or practice that I'm not following which is
causing me to fall over my own feet; I just wish I could figure out what it
is....
Anyway, if you can help me figure out what's wrong here, I'd be deeply
grateful.
This code is so close to finished it hurts. I really want to finish this.