Convert MDB for use on Windows 7

BABM

Registered User.
Local time
Today, 09:41
Joined
Oct 24, 2011
Messages
10
We have changed to windows 7 and I am trying to make all the right changes ot my existing 32 bit MDB to make it work correctly. I have read about adding PtrSafe to the declare functions and changing Long to LongPtr for handlers and pointers. I'm finding it hard to get my head around. I have listed my declare Functions below. Could anyone check to make sure they are now correct. Could someone check my code to make sure it is correct and which ones should be LongPtr or LongLong etc.
Also do I have to change Long in the following instances and what about Long data type in tables:

Example

Public Property Let MaxFileSize(vNewValue As Long)
'Assign object's MaxFileSize property
lMaxFileSize = vNewValue
End Property
Any help would be hugely appreciated. Thankyou!
MY CODE:::::::::::::
'API function called by ChooseColor method
Private Declare PtrSafe Function ChooseColor Lib "comdlg32.dll" Alias "ChooseColorA" (pChoosecolor As ChooseColor) As Long

'API function called by ShowOpen method
Private Declare PtrSafe Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OpenFilename) As LongPtr

'API function called by ShowSave method
Private Declare PtrSafe Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename As OpenFilename) As LongPtr

'API function to retrieve extended error information
Private Declare PtrSafe Function CommDlgExtendedError Lib "comdlg32.dll" () As LongPtr

'API memory functions
Private Declare PtrSafe Function GlobalAlloc Lib "kernel32" (ByVal wFlags As LongPtr, ByVal dwBytes As LongPtr) As LongPtr
Private Declare PtrSafe Function GlobalFree Lib "kernel32" (ByVal hMem As LongPtr) As LongPtr
Private Declare PtrSafe Function GlobalLock Lib "kernel32" (ByVal hMem As LongPtr) As LongPtr
Private Declare PtrSafe Function GlobalUnlock Lib "kernel32" (ByVal hMem As LongPtr) As LongPtr

Private Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
hpvDest As Any, hpvSource As Any, ByVal cbCopy As LongPtr)

Private Declare PtrSafe Function LoadLibrary Lib "kernel32" _
Alias "LoadLibraryA" (ByVal lpLibFileName As String) As LongPtr

Private Declare PtrSafe Function FreeLibrary Lib "kernel32" _
(ByVal hLibModule As Long) As LongPtr

Private Declare PtrSafe Function StopMouseWheel Lib "MouseHook" _
(ByVal hWnd As Long, ByVal AccessThreadID As Long, _
Optional ByVal bNoSubformScroll As Boolean = False, Optional ByVal blIsGlobal As Boolean = False) As Boolean

Private Declare PtrSafe Function StartMouseWheel Lib "MouseHook" _
(ByVal hWnd As Long) As Boolean

Private Declare PtrSafe Function GetCurrentThreadId Lib "kernel32" () As LongPtr

' Instance returned from LoadLibrary call
Private hLib As LongPtr

Public Declare PtrSafe Function ConvertUncompressedSnapshot Lib "StrStorage.dll" _
(ByVal UnCompressedSnapShotName As String, _
ByVal OutputPDFname As String, _
Optional ByVal CompressionLevel As Long = 0, _
Optional ByVal PasswordOwner As String = "", _
Optional ByVal PasswordOpen As String = "", _
Optional ByVal PasswordRestrictions As Long = 0, _
Optional PDFNoFontEmbedding As Long = 0 _
) As Boolean

' For debugging with Visual C++
'Lib "C:\VisualCsource\Debug\StrStorage.dll"

Private Declare PtrSafe Function ShellExecuteA Lib "shell32.dll" _
(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 LoadLibrary Lib "kernel32" _
Alias "LoadLibraryA" (ByVal lpLibFileName As String) As LongPtr

Private Declare PtrSafe Function FreeLibrary Lib "kernel32" _
(ByVal hLibModule As LongPtr) As LongPtr

Private Declare PtrSafe Function GetTempPath Lib "kernel32" _
Alias "GetTempPathA" (ByVal nBufferLength As LongPtr, _
ByVal lpBuffer As String) As Long

Private Declare PtrSafe Function GetTempFileName _
Lib "kernel32" Alias "GetTempFileNameA" _
(ByVal lpszPath As String, _
ByVal lpPrefixString As String, _
ByVal wUnique As Long, _
ByVal lpTempFileName As String) As LongPtr

Private Declare PtrSafe Function SetupDecompressOrCopyFile _
Lib "setupAPI" _
Alias "SetupDecompressOrCopyFileA" ( _
ByVal SourceFileName As String, _
ByVal TargetFileName As String, _
ByVal CompressionType As Integer) As LongPtr

Private Declare PtrSafe Function SetupGetFileCompressionInfo _
Lib "setupAPI" _
Alias "SetupGetFileCompressionInfoA" ( _
ByVal SourceFileName As String, _
TargetFileName As String, _
SourceFileSize As Long, _
DestinationFileSize As Long, _
CompressionType As Integer _
) As LongPtr
 
If you are still using the 32-bit version of Office...then I don't think this will work. Based on this MS article (http://msdn.microsoft.com/en-us/library/ee691831.aspx) it seems that Office 2010 64 bit version has the new VBA 7.0 and these new data types, but the 32-bit version does not. That being said I think you have the grasp of what you need to do assuming you are using the 64-bit version of Office 2010.
 
Thanks for the reply. It is the 64-bit version of office I'm running. The database is opening. There are some unexplained errors that are happening.

I only have a rough idea about changing the Declare functions and LongPtr. I was hoping someone with more sound knowledge than me could confirm I have changed the correct Longs and my syntax is correct.

Also do I have to change Long to LongPtr in other areas of code or queries or will they be OK as they are?
 
Hi I'm still stuck on this one and hoping someone can confirm my code. Anyone out there?
 

Users who are viewing this thread

Back
Top Bottom