+ Reply to Thread
Results 1 to 3 of 3

VBA code getting Compile error:

  1. #1
    Registered User
    Join Date
    09-25-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    88

    VBA code getting Compile error:

    Hi All,

    Please help!

    I have a vba code with the help of this code i am able to get data from audio files but this macro is working only in 32 bits system.

    when i run this macro in 64 bit i am getting error-The code in this project must be updated for use on 64-bit systems.Please review and update declare statements and then mark them with the PtrSafe attribute.

    i am getting error at-

    Please Login or Register  to view this content.
    Below is my complete code:-

    Please Login or Register  to view this content.
    error.jpg

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA code getting Compile error:

    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor
    Join Date
    03-16-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    371

    Re: VBA code getting Compile error:

    Did you try doing what the error message told you to do?

    See here: http://www.jkp-ads.com/articles/apideclarations.asp

    Snippet from link:
    Conditional compiling

    If your code needs to run on both 32 bit and 64 bit Excel, then another thing to do is add conditional compilation to your VBA.

    Microsoft devised two compile constants to handle this:

    VBA7: True if you're using Office 2010, False for older versions

    WIN64: True if your Office installation is 64 bit, false for 32 bit.

    Since the 64 bit declarations also work on 32 bit Office 2010, all you have to test for is VBA7:
    #If VBA7 Then
    Private Declare PtrSafe Function GetDeviceCaps Lib "gdi32" (ByVal hDC As LongPtr, ByVal nIndex As Long) As Long
    #Else
    Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hDC As Long, ByVal nIndex As Long) As Long
    #End If

    And then in the routine where this function is put to use:
    #If VBA7 Then
    Dim hDC As LongPtr
    #Else
    Dim hDC As Long
    #End If
    Dim lDotsPerInch As Long
    'Get the user's DPI setting
    lDotsPerInch = GetDeviceCaps(hDC, LOGPIXELSX)
    Design everything to be as simple as possible, but no simpler.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] code compile error
    By Burt_100 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-09-2015, 03:43 AM
  2. [SOLVED] Compile Error VBA error code attached
    By cgibson92 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-01-2015, 11:07 AM
  3. code generating compile error: syntex error
    By sankarsasmal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-10-2013, 05:29 AM
  4. [SOLVED] Compile Error in Hidden Module and Compile Error: Can't find project or library
    By Taislin in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-10-2013, 07:03 PM
  5. VBA Code problem - compile error
    By ExcelFailure in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-14-2013, 05:27 AM
  6. Compile Error in VBA Code
    By andrewc in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-22-2011, 06:49 AM
  7. VB code - compile error box help!!!
    By excel.xls in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-10-2007, 10:15 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1