Phoning With Outlook from Excel
-
- 5StarLounger
- Posts: 689
- Joined: 27 Jan 2010, 16:45
- Location: Ottawa, Ontario, Canada
Phoning With Outlook from Excel
Is it possible to pass a phone number from Excel to Outlook and have Outlook dial the number? I find VBA in Outlook to be inscrutable.
Regards
Don
Don
-
- Administrator
- Posts: 78489
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Phoning With Outlook from Excel
I agree that Outlook VBA is not intuititve, but be glad you're not automating PowerPoint! Compared to PowerPoint VBA, Outlook VBA is a breeze...
However, the Dial method in Outlook VBA only accepts an Outlook contact, not an arbitrary phone number. I tried the SendKeys method to pass a phone number from Excel to the New Call dialog, but SendKeys confirmed its reputation of being flaky - it didn't work.
Try this code from Andy Pope. Insert the following code at the top of a standard module:
You could call it like this in a macro:
or in the Worksheet_BeforeDoubleClick event procedure of a worksheet:
I don't have a phone modem in my PC, so I couldn't test it, but a connect dialog did appear, so hopefully it will work.
However, the Dial method in Outlook VBA only accepts an Outlook contact, not an arbitrary phone number. I tried the SendKeys method to pass a phone number from Excel to the New Call dialog, but SendKeys confirmed its reputation of being flaky - it didn't work.
Try this code from Andy Pope. Insert the following code at the top of a standard module:
Code: Select all
Declare Function tapiRequestMakeCall Lib "tapi32.dll" _
(ByVal stNumber As String, ByVal stDummy1 As String, _
ByVal stDummy2 As String, ByVal stDummy3 As String) As Long
Sub DialNumber(Number As String)
Dim lngStatus As Long
' Send the telephone number to the modem.
lngStatus = tapiRequestMakeCall(Number, "", "", "")
If lngStatus < 0 Then
MsgBox "Failed to dial number " & Number, vbExclamation
End If
End Sub
Code: Select all
Call DialNumber(Range("A1").Value)
Code: Select all
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Range("A2:A10"), Target) Is Nothing Then
Call DialNumber(Target.Value)
Cancel = True
End If
End Sub
Best wishes,
Hans
Hans
-
- Administrator
- Posts: 12606
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Re: Phoning With Outlook from Excel
Hans,
I just tested this code with Excel 2010 on Windows 7 and it worked fine.
I just tested this code with Excel 2010 on Windows 7 and it worked fine.
StuartR
-
- Administrator
- Posts: 78489
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- 5StarLounger
- Posts: 689
- Joined: 27 Jan 2010, 16:45
- Location: Ottawa, Ontario, Canada
Re: Phoning With Outlook from Excel
Thank you Hans
It works a treat on my 2003 installation.
I'm too embarrassed to explain why it took me so long to reply. (RTFM)
It works a treat on my 2003 installation.
I'm too embarrassed to explain why it took me so long to reply. (RTFM)
Regards
Don
Don
-
- 5StarLounger
- Posts: 689
- Joined: 27 Jan 2010, 16:45
- Location: Ottawa, Ontario, Canada
Re: Phoning With Outlook from Excel
Having successfully dialed a number, is it possible to close the Phone Dialer using VBA code?
Regards
Don
Don
-
- Administrator
- Posts: 78489
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Phoning With Outlook from Excel
Undoubtedly, but I don't know how to do that, sorry.
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 689
- Joined: 27 Jan 2010, 16:45
- Location: Ottawa, Ontario, Canada
-
- UraniumLounger
- Posts: 9284
- Joined: 13 Feb 2010, 01:27
- Location: Deep in the Heart of Texas
Re: Phoning With Outlook from Excel
But, but . . . but . . .
What if you use cable modem? How do you dial from your computer then? :evilgrin
What if you use cable modem? How do you dial from your computer then? :evilgrin
Bob's yer Uncle
Dell Intel Core i5 Laptop, 3570K,1.60 GHz, 8 GB RAM, Windows 11 64-bit, LibreOffice,and other bits and bobs
(1/2)(1+√5) |
-
- 5StarLounger
- Posts: 689
- Joined: 27 Jan 2010, 16:45
- Location: Ottawa, Ontario, Canada
Re: Phoning With Outlook from Excel
Perhaps we are becoming too accustomed to Hans having and sharing knowledge that is unfathomably deep to mere mortals.HansV wrote:Undoubtedly, but I don't know how to do that, sorry.
Again; Hans.
Regards
Don
Don
-
- Administrator
- Posts: 78489
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Phoning With Outlook from Excel
I actually don't know all that much, but I'm good at Googling. In this case, however, I only found very complicated code of which the authors complained that it didn't work consistently, so I didn't bother posting the code or a link to it here...
Best wishes,
Hans
Hans