Saltar al contenido
PROGRAMAR EN VBA MACROS DE EXCEL

Como ENVIAR WHATSAPP desde EXCEL a Nombre de CONTACTO NUEVA Version #502

Enviar Whatsapp a contacto agendado

Como ENVIAR WHATSAPP MASIVOS distintos a Cada Contacto

En este post veremos Como enviar whatsapp a nombre de contactos que tenemos registrados en el teléfono con Excel, es decir no se utilizará el número de teléfono sino en nombre del contacto registrado en el smartphone.

Necesitas aprender a usar excel?, click acá, si quieres aprender sobre Excel en inglés, entonces debes hacer click here. Si lo que necesitas es aprender o profundizar sobre la programación de macros con VBA este es unos de los mejores cursos on line que he visto en internet, te lo recomiendo no te arrepentirás.

  
 

En el vídeo verás la macro en acción con una explicación más detallada de su codificación y funcionamiento, recomiendo observar para una más fácil comprensión de la macro; suscribe a nuestro canal de You Tube, mira el playlist con  vídeos relacionados donde podrás ver la macros relacionadas en acción con una explicación en forma visual que ayudará a entender el ejemplo en forma más fácil.

Mensajes de WHATSAPP a Nombre de Contactos 

En el archivo de ejemplo que se puede descargar desde el final del post, se debe presionar el botón verde, mostrándose inmediatamente un formulario en el cual se debe seleccionar el contacto y el texto a enviar.

Este ejemplo funciona no con el número de teléfono sino con el nombre del contacto que figura en la aplicación Whatsapp, para ello se debe escribir en el Textbox el nombre del contacto y Selccionar uno.

Al escribir el nombre del contacto la macro busca en forma simultanea las coincidencias en la base de datos, que en este caso está en la hoja1, mostrándolas en el Listbox si existen varias coincidencias con lo escrito se debe seleccionar un contacto, en caso de que exista solo una coincidencia automáticamente se selecciona el nombre del contacto.

Si deseas ver como es la macro para este buscador inteligente, puedes ver el post Como Enviar Whatsapp en Forma Masiva desde Excel con Buscador Contacto o el post Punto de Venta con Excel – Busqueda de Clientes, aca solo se explicará como enviar Whatsapp a Nombre de Contacto con Excel.

Luego de seleccionado el contacto, o antes es indistinto, se debe seleccionar el texto haciendo doble click en el Textbox con mensajes pre-armados o bien escribir el menaje a enviar en el Textbox destinado a ello.

Por último se debe presionar el botón con el logo de Whatsapp, se ejecutará una macro que permite enviar el mensaje de Whatsapp  utilizando el nombre del contacto seleccionado.

Es preciso destacar que el aplicativo de Whatsapp Web debe estar descargado en nuestra PC de lo contrario no funcionará la macro.

Quizás también interese leer:

Como eliminar dato seleccionado del listbox y hoja excel con enter 
Como acelerar al maximo busqueda en listbox mientras se escribe en textbox 
Pasar datos listbox multiselect a distintas hoja excel dependiendo de condicion 

Si quieres aprender más sobre listbox de excel o ver otros ejemplos que podrías aplicar a tus proyectos te invito a ver el playlist sobre Listbox de Excel.

Explicación del Código que Envia Mensajes de Whatsapp utilizando el Nombre del Contacto Agendado

Cuando se presionó el botón para enviar el mensaje de Whatsapp a Nombre del Contacto registrado, se cargo en la variable «conw» el nombre del contacto y en la variable «textw» el texto a enviar, validando que dichas variables no se encuentren vacías en caso contrario finaliza la macro, se usa el siguiente código:

If conw = Empty Or textw = Empty Then
MsgBox («Debe ingresar contacto y texto para enviar Whatsapp»), vbCritical, «AVISO»
Exit Sub
End If

Si se validó que se ha seleccionado un contacto y se ha escrito un mensaje procede a abrir el aplicativo de Whatsapp Web que se encuentra en nuestra PC, con el código siguiente:

Shell «C:\Users\MyNotebook\AppData\Local\WhatsApp\WhatsApp.exe»

Ejecutándose Whatsapp Web en nuestra PC procede con el el comando Senkey a enviar o simularar impulsos de teclas con el objeto de enviar el mensaje de Whatsapp al contacto seleccionado, se usa el siguiente código:

Application.Wait (Now + TimeValue(«00:00:03»))
ActiveWindow.Application.SendKeys «{TAB}»
Application.Wait (Now + TimeValue(«00:00:01»))
Call SendKeys(conw, True)
Application.Wait (Now + TimeValue(«00:00:02»))
conw = Empty
ActiveWindow.Application.SendKeys «{TAB}»
ActiveWindow.Application.SendKeys «{TAB}»
ActiveWindow.Application.SendKeys «{TAB}»
‘ActiveWindow.Application.SendKeys «(~)»
Application.Wait (Now + TimeValue(«00:00:01»))
Call SendKeys(textw, True)
Application.Wait (Now + TimeValue(«00:00:01»))
ActiveWindow.Application.SendKeys «(~)» ‘énvia enter para enviar mensaje
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub



Descarga el archivo que muestra como enviar mensajes de Whatsapp utilizando el nombre del contacto del smarphone

Al final del post se encuentra el link de descarga es totalmente Gratis y no tiene ningún tipo de restricción, solicito aportar a sostener la esta web si está dentro de tus posibilidades, desde ya muchas gracias.

Código que se encuentra en el modulo 1

#If VBA7 And Win64 Then
‘Si es de 64 bits
Public Declare PtrSafe Function ShellExecute Lib «shell32.dll» Alias «ShellExecuteA» (ByVal hwnd As LongPtr, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPtr
Public Declare PtrSafe Function FindWindow Lib «user32» Alias «FindWindowA» (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
Public Declare PtrSafe Function GetWindowLongPtr Lib «user32» Alias «GetWindowLongPtrA» (ByVal hwnd As LongPtr, ByVal nIndex As Long) As LongPtr
Public Declare PtrSafe Function SetWindowLongPtr Lib «user32» Alias «SetWindowLongPtrA» (ByVal hwnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As LongPtr) As LongPtr
Public Declare PtrSafe Function DrawMenuBar Lib «user32» (ByVal hwnd As Long) As LongPtr
Public Declare PtrSafe Function RegOpenKeyA Lib «advapire32.dll» (ByVal hKey As LongPtr, ByVal lpSubKey As String, phkResult As LongPtr) As LongPtr
Public Declare PtrSafe Function GetWindowText Lib «user32» Alias «GetWindowTextA» (ByVal hwnd As LongPtr, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare PtrSafe Sub keybd_event Lib «user32» (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As LongPtr)
Public Declare PtrSafe Function GetForegroundWindow Lib «user32» () As LongPtr

#Else
‘Si es de 32 bits
Public Declare Function ShellExecute Lib «shell32.dll» Alias «ShellExecuteA» (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Public Declare Function FindWindow Lib «user32» Alias «FindWindowA» (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function GetWindowLong Lib «user32» Alias «GetWindowLongA» (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib «user32» Alias «SetWindowLongA» (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function DrawMenuBar Lib «user32» (ByVal hwnd As Long) As Long
Public Declare Function RegOpenKeyA Lib «advapire32.dll» (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Public Declare Function GetWindowText Lib «user32.dll» Alias «GetWindowTextA» (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Sub keybd_event Lib «user32» (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Public Declare Function GetForegroundWindow Lib «user32.dll» () As Long

#End If
Public conw, textw
Sub Muestra()
UserForm1.Show
End Sub

Sub EnviaWhatsapp()
‘*********** by marcrodos **** https://macrosenexcel.com *** https://www.youtube.com/c/programarexcel?sub_confirmation=1 ********

If conw = Empty Or textw = Empty Then
MsgBox («Debe ingresar contacto y texto para enviar Whatsapp»), vbCritical, «AVISO»
Exit Sub
End If

‘mylinkwhatsapp = «https://api.whatsapp.com/send?phone=» & telwhatsapp & «&text=» & textwhatsapp
‘ActiveWorkbook.FollowHyperlink mylinkwhatsapp
Shell «C:\Users\MyNotebook\AppData\Local\WhatsApp\WhatsApp.exe»

Application.Wait (Now + TimeValue(«00:00:03»))
ActiveWindow.Application.SendKeys «{TAB}»
Application.Wait (Now + TimeValue(«00:00:01»))
Call SendKeys(conw, True)
Application.Wait (Now + TimeValue(«00:00:02»))
conw = Empty
ActiveWindow.Application.SendKeys «{TAB}»
ActiveWindow.Application.SendKeys «{TAB}»
ActiveWindow.Application.SendKeys «{TAB}»
‘ActiveWindow.Application.SendKeys «(~)»
Application.Wait (Now + TimeValue(«00:00:01»))
Call SendKeys(textw, True)
Application.Wait (Now + TimeValue(«00:00:01»))
ActiveWindow.Application.SendKeys «(~)» ‘énvia enter para enviar mensaje
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub



Código que se encuentra en el userform1

Private Sub CommandButton1_Click()
conw = UserForm1.TextBox8
textw = UserForm1.TextBox1
Call EnviaWhatsapp
End Sub

Private Sub ListBox3_Click()
On Error Resume Next
ctlsaltachange = 1
UserForm1.TextBox8 = Empty
fila = UserForm1.ListBox3.ListIndex
UserForm1.TextBox8 = UserForm1.ListBox3.List(fila, 0)
UserForm1.TextBox9 = UserForm1.ListBox3.List(fila, 0) & » » & UserForm1.ListBox3.List(fila, 1) & » » & UserForm1.ListBox3.List(fila, 2)

UserForm1.ListBox3.Visible = False

If TextBox9 = Empty Then
UserForm1.Label2.Visible = True ‘hace visible el label
Else
UserForm1.Label2.Visible = False
End If

If TextBox8 = Empty Then
UserForm1.Label1.Visible = True ‘hace visible el label
Else
UserForm1.Label1.Visible = False
End If

ctlsaltachange = 0
End Sub

Private Sub TextBox2_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
TextBox1 = Clear
UserForm1.TextBox1 = TextBox2
End Sub
Private Sub TextBox3_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
TextBox1 = Clear
UserForm1.TextBox1 = TextBox3
End Sub

Private Sub TextBox4_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
TextBox1 = Clear
TextBox1 = TextBox4
End Sub

Private Sub TextBox5_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
TextBox1 = Clear
UserForm1.TextBox1 = «Expte: » & UserForm1.TextBox2 & » Caratula » & UserForm1.TextBox3
TextBox1 = TextBox5
End Sub

Private Sub TextBox6_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
TextBox1 = Clear
UserForm1.TextBox1 = «Expte: » & UserForm1.TextBox2 & » Caratula » & UserForm1.TextBox3
TextBox1 = TextBox6
End Sub

Private Sub TextBox7_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
TextBox1 = Clear
UserForm1.TextBox1 = «Expte: » & UserForm1.TextBox2 & » Caratula » & UserForm1.TextBox3
TextBox1 = TextBox7
End Sub

Private Sub TextBox8_Change()
If TextBox8 = Empty Then
UserForm1.Label1.Visible = True ‘hace visible el label
Else
UserForm1.Label1.Visible = False
End If
End Sub

Private Sub TextBox9_Change()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
On Error Resume Next
Dim cn As ADODB.Connection, rs As ADODB.Recordset

‘If ctlsaltachange = 1 Then Exit Sub

If TextBox9 = Empty Then
UserForm1.Label2.Visible = True ‘hace visible el label
Else
UserForm1.Label2.Visible = False
End If

If Len(UserForm1.TextBox9) <= 2 Then
UserForm1.ListBox3.Visible = False
Exit Sub
Else
UserForm1.ListBox3.Visible = True
End If

Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
Set a = Sheets(«Hoja1»)

cn.Open «Provider=Microsoft.ACE.OLEDB.12.0;» & «Data Source=» & ThisWorkbook.FullName & «;Extended Properties=»»Excel 12.0;HDR=Yes;»»»

If Len(UserForm1.TextBox9) > 2 Then
sql = «SELECT * FROM [» & «Hoja1$» & «] WHERE Ucase(» & a.Range(«A1») & «) LIKE Ucase(‘%» & UserForm1.TextBox9 & «%’) ORDER BY Nombre ASC»
Set rs = cn.Execute(sql)

UserForm1.ListBox3.Clear

Set rs = cn.Execute(sql)
If rs.EOF = True Then
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
UserForm1.ListBox3.Visible = False
Exit Sub
Else

UserForm1.ListBox3.Column = 3
UserForm1.ListBox3.ColumnWidths = «100 pt;70 pt;80 pt»

rs.MoveFirst
Do While Not rs.EOF
UserForm1.ListBox3.AddItem rs.Fields(0).Value
UserForm1.ListBox3.List(UserForm1.ListBox3.ListCount – 1, 1) = rs.Fields(1).Value
UserForm1.ListBox3.List(UserForm1.ListBox3.ListCount – 1, 2) = rs.Fields(2).Value
‘ Userform1.ListBox3.List(Userform1.ListBox3.ListCount – 1, 3) = rs.Fields(4).Value
‘ Userform1.ListBox3.List(Userform1.ListBox3.ListCount – 1, 4) = rs.Fields(5).Value
‘ Userform1.ListBox3.List(Userform1.ListBox3.ListCount – 1, 5) = rs.Fields(6).Value
rs.MoveNext
Loop
End If

End If
Set rs = Nothing
cn.Close
Set cn = Nothing

‘Si solo hay un dato coincidente directamente lo busca y carga sus datos, al seleccionarlo se ejecuta el evento click del listbox
If UserForm1.ListBox3.ListCount – 1 = 0 Then
‘El código 1 salta la programacion del evento change del combobox16 porque sino cuando la macro modifica se vuelve a ejecutar y se obtiene resultado no deseado
‘saltacbo16 = 1
‘La macro al seleccionar el item autoaticamente ejecuta la programacion del evento click que es la busqueda del dato y que
‘es lo que interesa en esta programación, por eso no se llama luego al evento listbox_click sino se ejecuta dos veces.
UserForm1.ListBox3.Selected(0) = True
‘Call ListBox3_Click
UserForm1.ListBox3.Visible = False
‘Se hace perder el foco al combobox16, porque sino se ejecuta la codificación del After_Update
‘Userform1.TextBox2.SetFocus
End If
‘salir:
‘Vuelve la variable a estado 0 para que se pueda ejecutar el evento change con otro registro
‘saltacbo16 = 0
Application.ScreenUpdating = True
Application.ScreenUpdating = True

End Sub
Private Sub UserForm_Initialize()
ExpteWhatsapp = «SUSCRIBE https://www.youtube.com/c/programarexcel?sub_confirmation=1»
UserForm1.TextBox1 = ExpteWhatsapp
UserForm1.TextBox2 = «Estimado recuerda » & ExpteWhatsapp & » activa la campanita y YouTube te avisara cuando se suba nuevo contenido «
UserForm1.TextBox3 = «Automatiza tus Libros Excel, tutoriales semanales, recuerda » & ExpteWhatsapp & » todas las semanas ideas sobre como automatizar tus libros Excel «
UserForm1.TextBox4 = «Mis datos son:» & Chr(13) & » https://www.youtube.com/c/programarexcel?sub_confirmation=1 » & Chr(13) & » comenta, dale LIKE si te fue útil»
UserForm1.TextBox5 = «Recuerda darle LIKE Y COMENTAR SI FUE UTIL: » & Chr(13) & «RECUERDA » & ExpteWhatsapp
UserForm1.TextBox6 = «Su próxima factura de ProgramarExcel.com vence el: » & Chr(13) & «14/06/2020 «
UserForm1.TextBox7 = «https://programarexcel.com Descarga cientos de ejemplos de Macros de Excel GRATIS, aporta al canal si puedes, sino con like, comentario y suscripción es suficiente»
End Sub



Si te fue de utilidad puedes INVITARME UN CAFÉ y de esta manera ayudar a seguir manteniendo la página, CLICK para descargar en ejemplo en forma gratuita.

If this post was helpful INVITE ME A COFFEE and so help keep up the page, CLICK to download free example.

Donate:
Cuenta Paypal: https://paypal.me/programarexcel
Cuenta Bitcoin: 1KBGGb8fyDzyR3X1Rie6m7VguzaAfngNbd
Cuenta Ether: 0x41Bbd24556914C83a31217eBb3BC49789b66e407

Summary
Author Rating
1star1star1star1star1star
Aggregate Rating
no rating based on 0 votes

Entradas relacionadas

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Comentarios (30)

I’m the owner of JustCBD label (justcbdstore.com) and am seeking to develop my wholesale side of company. I really hope that someone at targetdomain is able to provide some guidance ! I considered that the very best way to do this would be to talk to vape companies and cbd stores. I was hoping if anybody could recommend a reliable web-site where I can purchase CBD Shops B2B Sales Leads I am already reviewing creativebeartech.com, theeliquidboutique.co.uk and wowitloveithaveit.com. Unsure which one would be the most suitable solution and would appreciate any advice on this. Or would it be simpler for me to scrape my own leads? Suggestions?

Responder

комплекс специальных процедур, применяемых судом по заявлению юридического лица субсидиарная ответственность тема знакома каждому предпринимателю

Responder

Right here is the right website for everyone who wishes to understand this topic. You understand so much its almost hard to argue with you (not that I actually would want to…HaHa). You certainly put a new spin on a subject that’s been discussed for many years. Great stuff, just excellent!

Responder

An impressive share! I have just forwarded this onto a coworker who has been conducting a little research on this. And he actually bought me lunch simply because I found it for him… lol. So let me reword this…. Thanks for the meal!! But yeah, thanks for spending time to talk about this matter here on your blog.

Responder

Greetings! Very helpful advice within this post! It is the little changes that will make the most significant changes. Many thanks for sharing!

Responder

Aw, this was an extremely good post. Spending some time and actual effort to generate a good article… but what can I say… I put things off a lot and don’t seem to get nearly anything done.

Responder

I want to to thank you for this excellent read!! I absolutely loved every bit of it. I’ve got you saved as a favorite to check out new things you post…

Responder

There is certainly a lot to know about this issue. I really like all the points you have made.

Responder

May I simply say what a comfort to uncover someone that truly understands what they are discussing on the internet. You definitely know how to bring a problem to light and make it important. A lot more people should read this and understand this side of the story. I was surprised that you’re not more popular given that you definitely possess the gift.

Responder

Very good post. I’m dealing with some of these issues as well..

Responder

Good info. Lucky me I found your blog by chance (stumbleupon). I’ve book-marked it for later!

Responder

Pretty! This was an incredibly wonderful post. Thanks for supplying these details.

Responder

Aw, this was an exceptionally good post. Spending some time and actual effort to create a great article… but what can I say… I put things off a lot and don’t seem to get nearly anything done.

Responder

I used to be able to find good advice from your articles.

Responder

I’m excited to discover this web site. I want to to thank you for ones time just for this wonderful read!! I definitely liked every bit of it and I have you saved as a favorite to check out new information in your blog.

Responder

I truly love your site.. Excellent colors & theme. Did you build this website yourself? Please reply back as I’m attempting to create my very own site and would love to find out where you got this from or exactly what the theme is called. Thank you!

Responder

I could not resist commenting. Exceptionally well written!

Responder

You ought to take part in a contest for one of the highest quality sites on the net. I most certainly will recommend this blog!

Responder

Good day! I simply wish to give you a big thumbs up for the great info you’ve got right here on this post. I’ll be returning to your website for more soon.

Responder

Having read this I thought it was extremely informative. I appreciate you finding the time and energy to put this information together. I once again find myself spending a significant amount of time both reading and posting comments. But so what, it was still worthwhile!

Responder

It’s nearly impossible to find educated people in this particular topic, but you seem like you know what you’re talking about! Thanks

Responder

Wonderful article! We will be linking to this great content on our site. Keep up the great writing.

Responder

Aw, this was a very nice post. Taking the time and actual effort to create a really good article… but what can I say… I put things off a whole lot and don’t seem to get nearly anything done.

Responder

This website was… how do you say it? Relevant!! Finally I have found something which helped me. Many thanks!

Responder

Hi there, I do think your site could possibly be having internet browser compatibility problems. Whenever I take a look at your site in Safari, it looks fine but when opening in I.E., it’s got some overlapping issues. I simply wanted to give you a quick heads up! Aside from that, wonderful website!

Responder

Very good post. I am facing a few of these issues as well..

Responder

It’s hard to find well-informed people on this topic, but you seem like you know what you’re talking about! Thanks

Responder

There’s certainly a great deal to find out about this subject. I really like all of the points you’ve made.

Responder

You should be a part of a contest for one of the highest quality sites on the web. I will recommend this blog!

Responder

Can I just say what a comfort to find somebody who genuinely knows what they’re discussing on the internet. You certainly understand how to bring a problem to light and make it important. A lot more people must look at this and understand this side of the story. It’s surprising you aren’t more popular because you definitely possess the gift.

Responder