How do I change fix this code for 64 bit?

Kurt

Well-known Member
Joined
Jul 23, 2002
Messages
1,664
How do I change this code for 64 bit?

Code:
\Private Declare Function ShellExecute Lib "shell324dll" _
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

Sub SendEMail()
    Dim Email As String, Subj As String
    Dim Msg As String, URL As String
    Email = Cells(ActiveCell.Row, 10)
        
    Subj = Cells(ActiveCell.Row, 4)

    Msg = ""
    Msg = Msg & "Dear " & Cells(ActiveCell.Row, 1) & "," & vbCrLf & vbCrLf & "Here is some precanned text before the BODY info in the spreadsheet. " & vbCrLf & vbCrLf & Cells(ActiveCell.Row, 13) & vbCrLf & vbCrLf & " And here is some more precanned text in the macro AFTER the Body stuff."
    
    'Replace spaces with %20 (hex)
    Subj = Application.WorksheetFunction.Substitute(Subj, " ", "%20")
    Msg = Application.WorksheetFunction.Substitute(Msg, " ", "%20")
    
    'Replace carriage returns with %0D%0A (hex)
    Msg = Application.WorksheetFunction.Substitute(Msg, vbCrLf, "%0D%0A")
    
    'Create the URL
    URL = "mailto:" & Email & "?subject=" & Subj & "&body=" & Msg
    
    'Execute the URL (start the email client)
    ShellExecute 0&, vbNullString, URL, vbNullString, vbNullString, vbNormalFocus
    
    'Wait two seconds before sending keystrokes
    'Application.Wait (Now + TimeValue("0:00:02"))
    'Application.SendKeys "%s"
End Sub

Also do I need to turn any additional items on in References?
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Do you have Outlook? Why not use the Outlook.Application object?

Code:
Public Sub EM(noOptions As Byte)
Dim OutApp As Object
Dim OutMail As Object
Application.ScreenUpdating = False


Set OutApp = CreateObject("Outlook.Application")
On Error GoTo Cleanup
    Set OutMail = OutApp.CreateItem(0)
        OutMail.Recipients.Add Cells(ActiveCell.Row, 10)

        With OutMail
            .Subject = Cells(ActiveCell.Row, 4)
            .Body = "Here is some precanned text before the BODY info in the spreadsheet. "
            .Display
        End With
        Set OutMail = Nothing

Cleanup:
    Set OutApp = Nothing
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Do you have Outlook? Why not use the Outlook.Application object?

Code:
Public Sub EM(noOptions As Byte)
Dim OutApp As Object
Dim OutMail As Object
Application.ScreenUpdating = False


Set OutApp = CreateObject("Outlook.Application")
On Error GoTo Cleanup
    Set OutMail = OutApp.CreateItem(0)
        OutMail.Recipients.Add Cells(ActiveCell.Row, 10)

        With OutMail
            .Subject = Cells(ActiveCell.Row, 4)
            .Body = "Here is some precanned text before the BODY info in the spreadsheet. "
            .Display
        End With
        Set OutMail = Nothing

Cleanup:
    Set OutApp = Nothing
    Application.ScreenUpdating = True
End Sub

Because I have an Excel Spreadsheet where I want to list the reminders so someone can easily enter them there.
 
Upvote 0
But this code runs in Excel. Not sure what the problem is ??
 
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,174
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top