The code in this project must be updated for use on 64-bit systems. Please review and update Declare statements and then mark them with the PtrSafe a

Halos

New Member
Joined
Feb 14, 2015
Messages
34
Dear All,

I used office 32-bit but our PC changed to 64-bit. I need your help and code is below. If you put additional code, it will be good. I appreciate your help in advance.


Code:
[TABLE="width: 117"]
<colgroup><col></colgroup><tbody>[TR]
[TD]Private Declare Function ShellExecute Lib "shell32.dll" _[/TD]
[/TR]
[TR]
[TD]Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _[/TD]
[/TR]
[TR]
[TD]ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _[/TD]
[/TR]
[TR]
[TD]ByVal nShowCmd As Long) As Long[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]Sub Khalid()[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]reqem = InputBox("zehmet olmasa Password giriniz")[/TD]
[/TR]
[TR]
[TD]If reqem = 1111 Then GoTo dogrusayi[/TD]
[/TR]
[TR]
[TD]MsgBox "Password Sehvdir:("[/TD]
[/TR]
[TR]
[TD]Exit Sub[/TD]
[/TR]
[TR]
[TD]dogrusayi:[/TD]
[/TR]
[TR]
[TD]MsgBox "Password dogrudur:)"[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]    Dim Email As String, Subj As String[/TD]
[/TR]
[TR]
[TD]    Dim Msg As String, URL As String[/TD]
[/TR]
[TR]
[TD]    Dim r As Integer, x As Double[/TD]
[/TR]
[TR]
[TD]    For r = 2 To 15 'data in rows 6-8[/TD]
[/TR]
[TR]
[TD]'       Get the email address[/TD]
[/TR]
[TR]
[TD]        Email = Cells(r, 6)[/TD]
[/TR]
[TR]
[TD]        [/TD]
[/TR]
[TR]
[TD]'       Message subject[/TD]
[/TR]
[TR]
[TD]        [/TD]
[/TR]
[TR]
[TD]        [/TD]
[/TR]
[TR]
[TD]        Subj = "2018  salary review"[/TD]
[/TR]
[TR]
[TD]         [/TD]
[/TR]
[TR]
[TD]       [/TD]
[/TR]
[TR]
[TD]'       Compose the message[/TD]
[/TR]
[TR]
[TD]        Msg = ""[/TD]
[/TR]
[TR]
[TD]        Msg = Msg & "Dear " & Cells(r, 1) & "," & vbCrLf & vbCrLf[/TD]
[/TR]
[TR]
[TD]        [/TD]
[/TR]
[TR]
[TD]        Msg = Msg & "Following salary review for 2018 we are pleased to inform you that you are eligible for salary increase as outlined below:" & vbCrLf & vbCrLf[/TD]
[/TR]
[TR]
[TD]        [/TD]
[/TR]
[TR]
[TD]        Msg = Msg & "Current Gross Monthly Salary: " & "" & Cells(r, 2).Text & " " & "AZN Gross." & vbCrLf & vbCrLf[/TD]
[/TR]
[TR]
[TD]        [/TD]
[/TR]
[TR]
[TD]        Msg = Msg & "New Gross Monthly Salary: " & "" & Cells(r, 3).Text & " " & "AZN Gross." & vbCrLf & vbCrLf[/TD]
[/TR]
[TR]
[TD]        [/TD]
[/TR]
[TR]
[TD]        Msg = Msg & "Increase amount: " & "" & Cells(r, 4).Text & " " & "AZN Gross." & vbCrLf & vbCrLf[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]        Msg = Msg & "Effective Date: " & "" & Cells(r, 5).Text & " " & vbCrLf & vbCrLf[/TD]
[/TR]
[TR]
[TD]        [/TD]
[/TR]
[TR]
[TD]        Msg = Msg & "You will be contacted by HR representative within next week to provide you with the amendment to your employment contract as a formal confirmation of your salary increase.  Please do not hesitate to ask should you have any questions." & vbCrLf & vbCrLf[/TD]
[/TR]
[TR]
[TD]                 [/TD]
[/TR]
[TR]
[TD]        Msg = Msg & "Thanks for your contribution to the successful project delivery." & vbCrLf & vbCrLf[/TD]
[/TR]
[TR]
[TD]               [/TD]
[/TR]
[TR]
[TD]        Msg = Msg & "Your Sincerely" & vbCrLf[/TD]
[/TR]
[TR]
[TD]        Msg = Msg & "XXX" & vbCrLf[/TD]
[/TR]
[TR]
[TD]        [/TD]
[/TR]
[TR]
[TD]        Msg = Msg & "HR & Manager"[/TD]
[/TR]
[TR]
[TD]        [/TD]
[/TR]
[TR]
[TD]'       Replace spaces with %20 (hex)[/TD]
[/TR]
[TR]
[TD]        Subj = Application.WorksheetFunction.Substitute(Subj, " ", "%20")[/TD]
[/TR]
[TR]
[TD]        Msg = Application.WorksheetFunction.Substitute(Msg, " ", "%20")[/TD]
[/TR]
[TR]
[TD]                [/TD]
[/TR]
[TR]
[TD]'       Replace carriage returns with %0D%0A (hex)[/TD]
[/TR]
[TR]
[TD]        Msg = Application.WorksheetFunction.Substitute(Msg, vbCrLf, "%0D%0A")[/TD]
[/TR]
[TR]
[TD]'       Create the URL[/TD]
[/TR]
[TR]
[TD]        URL = "mailto:" & Email & "?subject=" & Subj & "&body=" & Msg[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]'       Execute the URL (start the email client)[/TD]
[/TR]
[TR]
[TD]        ShellExecute 0&, vbNullString, URL, vbNullString, vbNullString, vbNormalFocus[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]'       Wait two seconds before sending keystrokes[/TD]
[/TR]
[TR]
[TD]        Application.Wait (Now + TimeValue("0:00:02"))[/TD]
[/TR]
[TR]
[TD]        Application.SendKeys "%s"[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]    Next r[/TD]
[/TR]
[TR]
[TD]End Sub[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Dear All,

I used office 32-bit but our PC changed to 64-bit. I need your help and code is below. If you put additional code, it will be good. I appreciate your help in advance.


Code:
[TABLE="width: 117"]
<tbody>[TR]
[TD]Private Declare Function ShellExecute Lib "shell32.dll" _[/TD]
[/TR]
[TR]
[TD]Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _[/TD]
[/TR]
[TR]
[TD]ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _[/TD]
[/TR]
[TR]
[TD]ByVal nShowCmd As Long) As Long[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]Sub Khalid()[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]reqem = InputBox("zehmet olmasa Password giriniz")[/TD]
[/TR]
[TR]
[TD]If reqem = 1111 Then GoTo dogrusayi[/TD]
[/TR]
[TR]
[TD]MsgBox "Password Sehvdir:("[/TD]
[/TR]
[TR]
[TD]Exit Sub[/TD]
[/TR]
[TR]
[TD]dogrusayi:[/TD]
[/TR]
[TR]
[TD]MsgBox "Password dogrudur:)"[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]    Dim Email As String, Subj As String[/TD]
[/TR]
[TR]
[TD]    Dim Msg As String, URL As String[/TD]
[/TR]
[TR]
[TD]    Dim r As Integer, x As Double[/TD]
[/TR]
[TR]
[TD]    For r = 2 To 15 'data in rows 6-8[/TD]
[/TR]
[TR]
[TD]'       Get the email address[/TD]
[/TR]
[TR]
[TD]        Email = Cells(r, 6)[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]'       Message subject[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]        Subj = "2018  salary review"[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]'       Compose the message[/TD]
[/TR]
[TR]
[TD]        Msg = ""[/TD]
[/TR]
[TR]
[TD]        Msg = Msg & "Dear " & Cells(r, 1) & "," & vbCrLf & vbCrLf[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]        Msg = Msg & "Following salary review for 2018 we are pleased to inform you that you are eligible for salary increase as outlined below:" & vbCrLf & vbCrLf[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]        Msg = Msg & "Current Gross Monthly Salary: " & "" & Cells(r, 2).Text & " " & "AZN Gross." & vbCrLf & vbCrLf[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]        Msg = Msg & "New Gross Monthly Salary: " & "" & Cells(r, 3).Text & " " & "AZN Gross." & vbCrLf & vbCrLf[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]        Msg = Msg & "Increase amount: " & "" & Cells(r, 4).Text & " " & "AZN Gross." & vbCrLf & vbCrLf[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]        Msg = Msg & "Effective Date: " & "" & Cells(r, 5).Text & " " & vbCrLf & vbCrLf[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]        Msg = Msg & "You will be contacted by HR representative within next week to provide you with the amendment to your employment contract as a formal confirmation of your salary increase.  Please do not hesitate to ask should you have any questions." & vbCrLf & vbCrLf[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]        Msg = Msg & "Thanks for your contribution to the successful project delivery." & vbCrLf & vbCrLf[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]        Msg = Msg & "Your Sincerely" & vbCrLf[/TD]
[/TR]
[TR]
[TD]        Msg = Msg & "XXX" & vbCrLf[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]        Msg = Msg & "HR & Manager"[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]'       Replace spaces with %20 (hex)[/TD]
[/TR]
[TR]
[TD]        Subj = Application.WorksheetFunction.Substitute(Subj, " ", "%20")[/TD]
[/TR]
[TR]
[TD]        Msg = Application.WorksheetFunction.Substitute(Msg, " ", "%20")[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]'       Replace carriage returns with %0D%0A (hex)[/TD]
[/TR]
[TR]
[TD]        Msg = Application.WorksheetFunction.Substitute(Msg, vbCrLf, "%0D%0A")[/TD]
[/TR]
[TR]
[TD]'       Create the URL[/TD]
[/TR]
[TR]
[TD]        URL = "mailto:" & Email & "?subject=" & Subj & "&body=" & Msg[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]'       Execute the URL (start the email client)[/TD]
[/TR]
[TR]
[TD]        ShellExecute 0&, vbNullString, URL, vbNullString, vbNullString, vbNormalFocus[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]'       Wait two seconds before sending keystrokes[/TD]
[/TR]
[TR]
[TD]        Application.Wait (Now + TimeValue("0:00:02"))[/TD]
[/TR]
[TR]
[TD]        Application.SendKeys "%s"[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]    Next r[/TD]
[/TR]
[TR]
[TD]End Sub[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Try:

Code:
Private 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


Private 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
 
Upvote 0
Use the following condiftional compilation (#If etc) so that it will use the appropriate declaration for the version of Excel that opens the workbook:

Code:
#If VBA7 Then

Private 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

[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=Else]#Else[/URL] 

Private 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

[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=End]#End[/URL]  If
 
Upvote 0
Thank you all!

try:

Code:
private 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


private 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
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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