user1066231
user1066231

Reputation: 583

VBA macro specific to Excel 64bit

I want to write some macro specific to Excel 64 bit., the below link says about a macro, http://msdn.microsoft.com/en-us/library/office/gg264421.aspx

But it says "#if Win64" : Whether it reffers excatly office version..? because Users can install Office 32 bit 2010 in Windows 64 bit OS.

Upvotes: 1

Views: 1549

Answers (1)

Daniel
Daniel

Reputation: 13112

But it says "#if Win64" : Whether it reffers excatly office version..? because Users can install Office 32 bit 2010 in Windows 64 bit OS.

The Win64 constant used within a #If...then...#Else is a compiler constant. If it returns true, it indicates that the development environment is 64-bit compatible. Which means code written for a 32-bit environment may have issues.

In general the only conflict you may encounter between 32 bit VBA and 64 bit VBA is if you attempt to call outside Dlls via Declare. As described in the link you provided, the primary potential issue is this:

The problem with running legacy VBA code in 64-bit Office is that trying to load 64-bits into a 32-bit data type truncates the 64-bit quantity. This can result in memory overruns, unexpected results in your code, and possible application failure.

Probably your legacy code would still work, but you make the adjustment to assure that it will work.

The method of handling this is described in the link you provided where you provide the correct calling method for 64-bit within the #If...then...#Else structure using the compiler constants.

Upvotes: 1

Related Questions