32 bit worked now not on 64

fireslguk

Active Member
Joined
Nov 11, 2005
Messages
291
What do I need to change for this to work on 64 bit guys ?


Option Explicit



'Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _

'bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)



'Private Const KEYEVENTF_KEYUP = &H2

'Private Const VK_SNAPSHOT = &H2C

'Private Const VK_MENU = &H12

'Private Declare PtrSafe Sub Sleep Lib "kernel32.dll" ( _

' ByVal dwMilliseconds As Long)



'

' Public Sub mySleep()

'Do

'Application.Calculate

'ActiveSheet.Unprotect "6477"

'Sheets("MAIN").Range("b1").Value = Now

'ActiveSheet.Protect "6477"

'

' Call Sleep(2000) '2000 Millisekunden Pause

'Loop







'End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

ranman256

Well-known Member
Joined
Jun 17, 2014
Messages
2,012
find every DECLARE statement and put a PTRSAFE block to work on either 32 or 64bit:

Code:
#If Win64 Then      'Declare PtrSafe Function
Private Declare PtrSafe  Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare ptrsafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
 
Private Declare ptrsafe Function GetDesktopWindow Lib "user32" () As Long

#Else  'non ptrsafe

Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
private    Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
private  Declare Function GetDesktopWindow Lib "User32" () As Long

#End If
 

Forum statistics

Threads
1,144,366
Messages
5,723,942
Members
422,527
Latest member
TotalBeginner201

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
Top