Overflow error in custom ribbon ID

imran88

New Member
Joined
Aug 27, 2015
Messages
4
Hi,

I have been using this in my Excel VBA.

I successfully used it for Access by storing the value in a cell of Table which was working fine. But recently it was creating ID that was beyond the limit of Long Data Type

Here is the value that was stored in the Table
2776162645616
and I am receiving

Snag_48fcc7b.png

Can RoryA or someone else help in this regard.
 
Last edited by a moderator:

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,510
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Are you using 64bit Office?
 

imran88

New Member
Joined
Aug 27, 2015
Messages
4
Thanks Rory for the review.

Yes I am using using 64-bit office and here is the code I was using and it was working fine until the value of id went beyond the scope of Long Data Type and I am getting the overflow error

VBA Code:
#If VBA7 Then
    Public Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As LongPtr)
#Else
    Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
#End If



#If VBA7 Then
Function GetRibbon(ByVal lRibbonPointer As LongPtr) As Object
#Else
Function GetRibbon(ByVal lRibbonPointer As Long) As Object
#End If
        Dim objRibbon As Object
        CopyMemory objRibbon, lRibbonPointer, LenB(lRibbonPointer)
        Set GetRibbon = objRibbon
        Set objRibbon = Nothing
End Function
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,510
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Sounds like somewhere in your code (in the parts you haven't posted) you're trying to use a Long to hold the value of the pointer, but it needs to be a LongLong or LongPtr in 64bit Office.
 

imran88

New Member
Joined
Aug 27, 2015
Messages
4
Sounds like somewhere in your code (in the parts you haven't posted) you're trying to use a Long to hold the value of the pointer, but it needs to be a LongLong or LongPtr in 64but Office.
Thanks Rory

I will read my full code once again and will comeback to let you know in either case.
 

Watch MrExcel Video

Forum statistics

Threads
1,128,020
Messages
5,628,181
Members
416,297
Latest member
Kara Payne

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top