# Excel 2008 --> Run time error 13: Type mismatch



## zCJH4254 (Feb 6, 2009)

Greetings!

I don't get it. Our code was running just fine, and now we are getting a Run time error 13: Type mismatch. I have checked with the other person the works on our code and neither of us changed anything that would appear to generate this error.

The error is occurring at the line:


```
Set AllAnnots = jso.GetAnnots(intI)
```
The entire function is:


```
Public Function GetStampValue(oldAndNew As Boolean) As String
    Dim AllAnnots
    Dim Annot
    Dim props
    Dim intStampCount As Integer
    Dim intI As Integer
    Dim intNumWords As Integer
    Dim strTempStampValue As String
    
    blnStampFound = False
    blnMoreThanOneStamp = False
    intStampCount = 0
    GetStampValue = ""
    intGoodStampValues = 0
    strPLMLifeCycle = ""

    'oldAndNew controls whether any found stamps will be checked against all the engineering stamps in the database whether they are the
    'latest or an obsolete stamp.  This is used for a bulk release function where we do not want to load any files that have an engineering
    'stamp (latest or obsolete)

    For intI = 0 To jso.numpages - 1
        
        ' Don't really care how many words - this was the only way I found to go to the next page
        intNumWords = jso.getPageNumWords(intI)
        
        jso.syncannotscan
        Set AllAnnots = jso.GetAnnots(intI)
        
        ' If AllAnnots is 'Empty', then there are no Stamps in the file
        If Not IsEmpty(AllAnnots) Then
            For Each Annot In AllAnnots
                
                Set props = Annot.getprops()
                
                If props.Type = "Stamp" Then
                    blnStampFound = True
                    intStampCount = intStampCount + 1
                    
                    strTempStampValue = props.Subject
                
                    ' Check each stamp as it is found
                    If IsStampValid(strTempStampValue, oldAndNew) Then
                        intGoodStampValues = intGoodStampValues + 1
                    End If
                    
                End If
                
            Next Annot
        End If
            
    Next intI
    
    ' 1/11/2008 - No Longer needed
    '
    '' Logic to determine if more than one stamp was found.
    '' If so, set boolean to True and set GetStampValue = ""
    'If intStampCount > 1 Then
    '    blnMoreThanOneStamp = True
    '    GetStampValue = ""
    'End If
    
    
    ' 1/11/2008 - New Logic - If there is one and only
    If intGoodStampValues = 1 Then
        blnValidStamp = True
    Else
        blnValidStamp = False
        strPLMLifeCycle = ""
    End If
                    
    Set AllAnnots = Nothing
    Set Annot = Nothing
    Set props = Nothing

    GetStampValue = ""     'doesn't matter what is in this variable any more

End Function
```
Any ideas or help would be appreciated.

Charlie


----------



## Aftab (Oct 15, 2003)

Can you paste the jso.GetAnnots method. The error might be in there.


----------



## JimmySeal (Sep 25, 2007)

I don't know much about visual basic or this JSObject you seem to be using, but since getAnnots returns an array, maybe you need to declare AllAnnots as an array?


----------

