一連の番号を自動的にダイヤルするかなり単純なスクリプトを使用しています。私のコンピューター (モデムが組み込まれたラップトップ) では正しく動作しますが、同僚のコンピューター (最初にスクリプトが設計された相手) では最初の番号で動作し、その後はまったく動作しません (モデムが勝った)コンピューターを再起動しない限り、どの番号にもダイヤルせず、エラーも表示されません)。この動作を説明できる設定または mscomm プロパティはどれですか? 通話の終わりにスピーカーを閉じて、新しい通話の開始時に開かないのではないかと思います...
Dim CancelFlag As Integer
Dim RingCount As Integer
Dim raccrocherFlag As Integer
' Démarrage
Private Sub btnStart_Click()
' On Error GoTo Gest_err
For Each numtel In Sheets("ListeTRS").Range("b2:b10000")
' Si bouton Cancel a été pressé, on arrête le script
If CancelFlag = 1 Then
UserForm1.Hide
Exit Sub
End If
valNumtel = Val(numtel)
If valNumtel = 0 Then
MsgBox "Fin de fichier."
Exit Sub
Else
ActiveSheet.Range("A" & numtel.Row).Select
If Application.Wait(Now + TimeValue("0:00:2")) Then Dial numtel, numtel.Row
End If
Next
End Sub
Private Sub Dial(Number, Indice)
Dim DialString As String
Dim FromModem As String
Dim dummy As Integer
' AT is the Hayes compatible ATTENTION command and is required to send commands to the modem.
' DT means "Dial Tone." The Dial command uses touch tones, as opposed to pulse (DP = Dial Pulse).
' Numbers is the phone number being dialed.
' A semicolon tells the modem to return to command mode after dialing (important).
' A carriage return, vbCr, is required when sending commands to the modem.
' Concatene 0 avant le numéro
dialnumber = "0" & Number
DialString = "ATDT" + dialnumber + ";" + vbCr
' Communications port settings.
' A faire > detecter le port ou le demander à l'usager?
Dim comPort As Integer
comPort = 3
MSComm1.CommPort = comPort
MSComm1.Settings = "9600,N,8,1"
RingCount = 0
On Error Resume Next
' Ouvrir le port s'il est fermé
If (MSComm1.PortOpen = False) Then
MSComm1.PortOpen = True
End If
If Err Then
MsgBox "COM" & comPort & " n'est pas disponible. Changer la propriété à un autre port."
Exit Sub
End If
' Flush the input buffer.
MSComm1.InBufferCount = 0
' Dial the number.
Sheets("ListeTRS").Range("D" & Indice).Value = "Appel en cours du " & dialnumber & " § " & Now
MSComm1.Output = DialString
' On attend 10 seconde puis on lis les infos disponible dans le tampon du modem
If Application.Wait(Now + TimeValue("0:00:20")) Then
FromModem = FromModem + MSComm1.Input
End If
' Raccrocher
MSComm1.Output = "ATH" + vbCr
' Disconnect the modem.
MSComm1.Output = "ATH" + vbCr
' Close the port.
MSComm1.PortOpen = False
End Sub
Private Sub cmdStop_Click()
CancelFlag = 1
End Sub
Private Sub Worksheet_Activate()
'Setting InputLen to 0 tells MSComm to read the entire contents of the
'input buffer when the Input property is used.
MSComm1.InputLen = 0
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel As Boolean)
Dim Number As String
' Get the number to dial.
Number = Target.Value
If Number = "" Then Exit Sub
' Dial the selected phone number.
Dial (Number)
End Sub