Solved

VBA: Declarations for 64-bit versions of libraries

Posted on 2016-10-28
3
209 Views
Last Modified: 2016-10-31
I have code that includes declarations of 32-bit Microsoft libraries.  Some of our users are now just migrating to 64-bit versions of Office and I want the code to work on both.  I tried to look around for the 64-bit equivalents of the 32-bit declarations, but no luck.  Our code works for those running MS Access 2010 but not MS Access 2013 64-bit.

Any help would be much appreciated.  Here are the 32-bit declarations:

Declare Function IsZoomed Lib "user32" (ByVal hwnd As Long) As Long
Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Declare Function AddPrinterConnection Lib "winspool.drv" Alias "AddPrinterConnectionA" (ByVal pName As String) As Long
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
0
Comment
Question by:koughdur
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 250 total points
ID: 41864748
you need to  add PtrSafe in the declaration and the value LongPtr is used instead of Long

in 32 bit you will declare
Declare Function GetActiveWindow Lib "User32" () As Long

in 64 bit use
Declare PtrSafe Function GetActiveWindow Lib "User32" () As LongPtr


see these links for more information
Declare64bit
Declare64bit_1
0
 
LVL 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 250 total points
ID: 41864830
Sounds like you are on your way, but here are some things that will help:

This is an overview.  Make sure you read the section "Introducing the VBA 7 Code Base"

Compatibility Between the 32-bit and 64-bit Versions of Office 2010
http://msdn.microsoft.com/en-us/library/ee691831(office.14).aspx


There is also a code inspector for 64 bit:

Microsoft Office Code Compatibility Inspector user's guide
http://technet.microsoft.com/en-us/library/ee833946.aspx

 which will tell you what needs to be changed.

Here is a list of all the new 64 bit calls:

http://www.microsoft.com/download/en/confirmation.aspx?displaylang=en&id=9970

and here's a list of all the calls that were modified for 64 bit:
http://msdn.microsoft.com/en-us/library/aa383663(VS.85).aspx

Jim.
0
 

Author Closing Comment

by:koughdur
ID: 41867004
Thank you SOOOO much!  This is all very helpful.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question