OS Specific VBA Code
Does your clients report OS related issues often?
The Vba macro might end up in Microsoft 32 bit or 64 bit or a Mac IOS system. How to make a Vba code compatible with different Operating systems.
Here is the 2 simple methods to determine OS version within Excel Macro.
64 bit Vs 32 bit or Windows Vs Mac IOS
Introduction of 64 bit machines has many advantages. But still it is a headache for the many developers. Since they have to migrate their old programmed codes from 32 bit to 64 bit.
They have to add bunch of code to do this verification. If you are looking to convert your already delivered 32-bit version of VBA to 64 bit version, then refer this article.
How To find OS Version using VBA?
Well, there are 2 methods.
Determine Operating system in Excel VBAVisual Basic123456789101112131415161718Sub Find_Operating_System()'Get Operating System Name using Application ObjectMsgBox Application.OperatingSystem'OS Details using Pre-Processor Directive#If Mac ThenMsgBox "Mac IOS Computer"#Else#If Win64 Then'Microsoft Office - 64 bit versionMsgBox "Windows 64 bit Operating system"#Else'Microsoft Office - 32 bit versionMsgBox "Windows 32 bit Operating system"#End If#End IfEnd Sub
- Application.Operating system is the widely used function that you will get in most of the websites. But there is another method too.
- Using Vba pre-processor directives. Lets see what is it all about.
Yes. VBA has inbuilt pre-processor directives to categorize operating ssytem. This method is also used to find if the code is executed in Mac or Windows.
When you refer the other article to convert 32-bit to 64 bit, this same directives are used to categorize the declaration of public variables.
This issue come mainly when you use any windows API function within your code.
Determine Operating System – Excel VBA Macro – Find OS Details
- Games VCF Countif Record Macro Timer in Excel Task Manager print screen HTML Table Import Data Thumbnails Text to Speech TTS Candy Crush Block Apps in FaceBook C++ Programing Machine learning AI bulk email Excel VBA vba color index vba color codes Android social media Twitter Google+ Google Adsense Tips bitcoin Calendar in Excel outlook vba mass email Data Mining Excel Macro Facebook WhatsApp python Wordpress