I get an communication error every time I enter the Read function of the object SMS3ASuiteLib.ISMSMemory. I don't know what I do wrong. I wrote the following in VBA (Excel). Can somebody help me?
Private SMSMemory As SMS3ASuiteLib.ISMSMemory
Private puSMSSuiteAdapter As SMS3ASuiteLib.SMS_SuiteAdapter
Public InfoAdapter As New STTNGS3A_SLib.PhoneInfo_Suite3
Private Function GetDeviceStatus() As Boolean
'True is connection, False is no connection
Dim PhoneStatus As STTNGS3A_SLib.IPhoneStatus
Dim CommErrorRetries As Integer
Dim devStatus As DevNotifyOpt
On Error GoTo ErrorTrap
Set PhoneStatus = InfoAdapter
CommErrorRetries = 0
Beginning:
With InfoAdapter
'Device status opvragen
Call .get_DeviceStatus(devStatus)
Select Case devStatus
Case ATTACHED
WriteLog "Connectie aanwezig", ""
GetDeviceStatus = True
Case REMOVED
WriteLog "Connectie verwijderd", ""
GetDeviceStatus = False
Case UNKNOWN
WriteLog "Connectie onbekend?????", ""
GetDeviceStatus = False
End Select
End With
Exit Function
ErrorTrap:
'Error afhandeling
Dim err As NmpAdapterError
err = InfoAdapter.GetLastError
Select Case err
Case errCommunicationError
CommErrorRetries = CommErrorRetries + 1
If CommErrorRetries > 5 Then
MsgBox "Communicatie Error", vbCritical, "ERROR"
Else
GoTo Beginning
End If
Case Else
MsgBox "Error: " & err, vbCritical, "Error"
GetDeviceStatus = False
End Select
End Function
Private Sub UserForm_Activate()
Dim error As Boolean
On Error GoTo errHandle
deleteLog
Row = 1 'Regel voor log op de eerste regel zetten
Set puSMSSuiteAdapter = New SMS3ASuiteLib.SMS_SuiteAdapter
Set SMSMemory = puSMSSuiteAdapter
error = GetDeviceStatus 'Vraag status op
On Error GoTo 0
If error = True Then 'Is er verbinding dan doorgaan
test
Else
End
End If
Exit Sub
errHandle:
WriteLog "Onbekende fout opgetreden", ""
Unload Me
End Sub
Sub test()
ReadMessage DEFAULT_MEMORY, 1, 0
End Sub
Private Sub ReadMessage( _
SMSMemType As SMS_MEMORY_LOCATION, _
MemoryIndex As Long, _
MarkMessageAsRead As Long)
Dim MessageText As String
Dim Msg As New SMS3ASuiteLib.ShortMessage
Dim AantalSMS As Long
'Read the Message
Call SMSMemory.Read(SMSMemType, MemoryIndex, Msg, MarkMessageAsRead)
MessageText = "Message from " & Msg.OtherEndAddress & ": " & _
Msg.UserDataText
If MarkMessageAsRead Then
MessageText = MessageText & "Message has been marked as read."
End If
MsgBox MessageText
Exit Sub
ErrorTrap:
If SMSMemory.GetLastError = 0 Then
MessageText = "Message from " & Msg.OtherEndAddress & ": " & _
Msg.UserDataText
If MarkMessageAsRead Then
MessageText = MessageText & "Message has been marked as read."
End If
MsgBox MessageText
Else
MsgBox "Error: " & SMSMemory.GetLastError & " Tijdens het ophalen van het sms bericht."
End If
End Sub