Solved

VBA: Declarations for 64-bit versions of libraries

Posted on 2016-10-28
3
112 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
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 57

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Hi Everyone I posted previously on how I used Orchestrator to integrate with VMware and SCSM to create or request a new VM in VMware. Now in my Self Service Portal I had a list user input option that would require me to update the list of reso…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

830 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