De: Relative Zero Objet: Re: Dial-up connection from VBA Date : mercredi 27 décembre 2000 08:00 Malone, In response to article > Is it possible to open just a Dial-Up Connection from within VBA? If you are using Excel 2000 I understand that there is an option under the File menu for dialing direct from excel which you record with the macro recorder otherwise you will need to resort to one of the following solutions. John Lacher provides an Excel spreadsheet which dials phone numbers using the Windows 95 Dialer and Windows3.11 Cardfile. The spreadsheet can be found at http://lacher.com/examples/lacher35.htm. John's solution uses sendkeys to transfer the number from cells on your spreadsheet to the dialing application. John Walkenbach also details a sendkeys solution in "Microsoft Excel 2000 Power Programming with VBA" An alternative approach is to use Telephony Application Programming Interface (TAPI) which is supplied with: * Windows NT 4.0 SP3 or later. * Windows 95 or later. For further information on tapiRequestMakeCall refer to: http://msdn.microsoft.com/library/psdk/tapi22/func1_3vcc.htm Additional TAPI support can be found in the online "MAPI, SAPI, TAPI Developer's Guide" by Michael C. Amundsen at: http://kitap.ankara.edu.tr/0672309289/index.htm I have included some code which includes a 'wrapped' subroutine for the TAPI function (Dial) together with a very basic routine (Reader) for transferring your numbers from a range (Phone) in your spreadsheet to the dialing application. Obviously the details of this routine depend on your requirements. To set your own location, number and any numbers required to dial out from your phone run dialer.exe and set preferences as required. These preferences are stored in Telephon.ini ____________________________________________________________________________ Option Explicit Private Declare Function tapiRequestMakeCall& Lib "TAPI32.DLL" _ (ByVal DestAddress$, ByVal AppName$, ByVal CalledParty$, ByVal Comment$) ' Possible error return values from tapiRequestMakeCall function Private Const TAPIERR_NOREQUESTRECIPIENT = -2& Private Const TAPIERR_REQUESTQUEUEFULL = -3& Private Const TAPIERR_INVALDESTADDRESS = -4& Private Const TAPIERR_INVALPOINTER = -18& Sub Dial(strPhoneNo As String, Optional strCalledParty As String, _ Optional strComment As String, Optional bError As Boolean) Dim strErr As String Dim lngResult As Long ' Assign Default values to optional arguments If IsMissing(strCalledParty) Then strCalledParty = "" If IsMissing(strComment) Then strComment = "" If IsMissing(bError) Then bError = True lngResult = tapiRequestMakeCall&(Trim(strPhoneNo), _ CStr(Caption), strCalledParty, strComment) 'Display error message unless requested otherwise If bError And lngResult <> 0 Then strErr = "Error dialing " + strPhoneNo + ": " Select Case lngResult Case TAPIERR_NOREQUESTRECIPIENT strErr = strErr & "Unable to start/use Dialing application." Case TAPIERR_REQUESTQUEUEFULL strErr = strErr & "Dialing requests queue is full." Case TAPIERR_INVALDESTADDRESS strErr = strErr & "Phone number is invalid." Case TAPIERR_INVALPOINTER strErr = strErr & "Pointer error." ' This error should not occur Case Else strErr = strErr & "Unknown error." ' The four errors listed are all of the current function ' error returns but who knows what the future will bring End Select MsgBox strErr, vbOKOnly + vbExclamation, "Dialing Error" End If End Sub Sub Reader() Dim rngPhone As Range Dim rngCell As Range set rngPhone = Application.Range("Phone") For Each rngCell In rngPhone Dial (rngCell.Value) Next rngCell End Sub -- Regards, Vaughan Griffiths Relative Zero P/L