Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Cómo usar Función Shell para Excel VBA en MAC

publicado

Buenas noches amigos,

Por favor, alguien podría ayudarme con esta duda. Este código que envía mensajes de información que esta en excel, a través de WhastApp, me funciona correctamente en windows, pero necesito adaptarlo para que funciones en un Excel de un ordenador MAC.

Creo entender que el problema lo tengo en la ejecución de la función SHELL que inicializa la aplicación, pero no se que adaptación debo hacer para que sea operativo en MAC.

De antemano agradezco su valiosa ayuda.

Declare PtrSafe 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
Const SW_NORMAL = 1  'para optimizar la aplicación
Sub envioCartera()
Application.ScreenUpdating = True ' Inabilitar la pantalla
'Application.EnableEvents = False
'ActiveSheet.DisplayPageBreaks = False

Dim Rango As Range
Dim x
Dim Mensaje, saludo, cuerpo, cierre, archivo As String
Dim i, fila, id1, id2, id3, y, k, t1, t2 As Integer
archivo = ThisWorkbook.Name

Call SendKeys("{NUMLOCK}", True)
'loExcel = CreateObject("Excel.Application")
'ReturnValue = Shell("C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE")
Workbooks(archivo).Activate
fila = Hoja1.Cells(Rows.Count, 2).End(xlUp).Row
If fila >= 3 Then

    Hoja3.Range("c11") = Now
    
    saludo = Hoja3.Range("b4").Text
    cuerpo = " " & Hoja3.Range("c4").Text
    cierre = Hoja3.Range("d4").Text
    id1 = Hoja3.Range("B6").Value
    id2 = Hoja3.Range("C6").Value
    
    
    For i = 3 To fila
     'For Each Rango In Hoja1.Range("Cartera[Cliente]") 'Nombre de la tabla y columna
        Mensaje = VBA.Replace("whatsapp://send?phone=" & Hoja1.Cells(i, 5).Text & Hoja1.Cells(i, 4).Value & "&text=" & saludo & Chr(13) & Chr(13) & "%20" & Hoja1.Cells(i, id1) & Chr(13) & "%20" & cuerpo & " " & FormatCurrency(Hoja1.Cells(i, id2), 0) & " " & cierre, " ", "%20")
        
        Application.Wait Now + TimeValue("00:00:03")
        
        x = ShellExecute(hwnd, "Open", Mensaje, &O0, &O0, SW_NORMAL)  'Para obtener el mensaje
        
        Application.Wait Now + TimeValue("00:00:06")
        
            Call SendKeys("{NUMLOCK}", True)
            Call SendKeys("~", True)  'El caracter ~ es para presionar enter y enviar el mensaje
            Call SendKeys("{NUMLOCK}", True)
            
        
        Next i


'AppActivate "Excel", 1
Workbooks(ThisWorkbook.Name).Activate   'Volver la ventana
Hoja1.Select
Call SendKeys("{NUMLOCK}", True)
Hoja3.Range("c12") = Now
MsgBox ("Mensaje con Exito"), vbInformation
Application.ScreenUpdating = True ' Habilitar la pantalla lo que hace
Application.EnableEvents = True

Else
MsgBox "No hay contactos", vbCritical, "excelparatodos.com"
End If

End Sub

Featured Replies

publicado

Si no recuerdo mal, en Mac debes sustjituir la función ShellExecute por MacScript. 

Presta atención a las direcciones de los archivos. En windows se usa la diagonal invertida para separar carpetas. En Mac se usa la diagonal normal.

Atención también a los nombres de las teclas. Las teclas "no alfabéticas" no tienen los mismos nombres en Windows y en Mac.

También he visto que se hace referencia al objeto ActiveSheet. No estoy seguro de si en Mac funciona. No obstante puedes usar Worksheet(indice) para hacer referencia a la hoja.

 

Espero haber dado algo de luz a tu duda.

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.