Overflow error in custom ribbon ID

imran88

New Member
Joined
Aug 27, 2015
Messages
5
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:

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Are you using 64bit Office?
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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
Back
Top