+ Reply to Thread
Results 1 to 3 of 3

How to know which lib has to be referred to while using PTRsafe

  1. #1
    Registered User
    Join Date
    11-19-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    1

    How to know which lib has to be referred to while using PTRsafe

    Shubh Shubh ho !!

    I have vba code in a macro enabled file, in MS Office Professional Plus 2019.

    When this is opened in LTSC 2021 version of XL, error is displayed and macros cant be run.

    From my attempts to understand, it appears that my XL is in 32 bit whereas the target system is a 64bit.

    I also understood that we need to use PTRsafe keyword in functions, like
    private declare ptrsafe function swe_azalt lib "swedll32.dll" ......

    I have only one custom Function in my code, very simple in nature.

    From the declare line above, it appears to be referring to a library "swedll32.dll"
    And in other examples on the net, there are different libraries being referred to.

    Now my question is, how to know which library my code has to refer.
    =======================================
    My function code is as below.
    Function CenterRight(ByVal lMsg As Long, ByVal wParam As Long, _
    ByVal lParam As Long) As Long
    Dim rectXL As RECT, rectMsg As RECT
    Dim x As Long, y As Long
    Dim hMsgbox As Long
    If lMsg = HCBT_ACTIVATE Then
    hMsgbox = GetActiveWindow
    GetWindowRect hXL, rectXL
    GetWindowRect wParam, rectMsg
    x = (rectXL.Left + (rectXL.Right - rectXL.Left) * 0.9) - _
    ((rectMsg.Right - rectMsg.Left) / 2)
    y = ActiveWindow.Height / 2
    SetWindowPos wParam, 0, x, y, 0, 0, _
    SWP_NOSIZE Or SWP_NOZORDER Or SWP_NOACTIVATE
    UnhookWindowsHookEx hHook
    End If
    CenterRight = False
    End Function
    =================================

    Is there any thing else to be modified or kept in mind, so that the code can get executed in the target system without errors.

    Thanks in advance

  2. #2
    Forum Contributor
    Join Date
    10-02-2012
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    252

    Re: How to know which lib has to be referred to while using PTRsafe

    That's not exactly how PtrSafe works. But from your function it looks like you're calling the user32 library.
    Last edited by PrizeGotti; 11-16-2023 at 09:41 AM.

  3. #3
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,915

    Re: How to know which lib has to be referred to while using PTRsafe

    See here: https://learn.microsoft.com/en-us/of...ions-of-office

    If you already have working code, it already refers to the correct lib files. You just need to update it to work with 64 bit (which is, as per the link, more involved than just adding PtrSafe).
    Rory

+ 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. PtrSafe Function
    By RJ1969 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-12-2022, 10:45 PM
  2. PtrSafe not working
    By KevBotes in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-06-2020, 08:30 AM
  3. PtrSafe error for Inserting Sound File
    By Little Master in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-27-2019, 03:00 PM
  4. Referred cell different format
    By harperg11 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-20-2016, 04:57 PM
  5. [SOLVED] PtrSafe attribute for 64 bit system
    By MissDB in forum Excel - New Users/Basics
    Replies: 11
    Last Post: 04-08-2014, 05:43 AM
  6. e cell referred to in a UDF?
    By Excel2010101 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-31-2014, 01:15 AM
  7. Conditional format but referred from other cell
    By Lamb Chop in forum Excel General
    Replies: 2
    Last Post: 07-28-2006, 04:55 PM

Tags for this Thread

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