Consulting

Results 1 to 5 of 5

Thread: Ribbon run-time error 5825

  1. #1
    VBAX Newbie
    Joined
    Jan 2021
    Posts
    4
    Location

    Ribbon run-time error 5825

    Hi Greg/All,

    Good Day. I am new to VBA and have been handling VBA Macro(Word-Addin). My Macro is designed as Word Ribbons in word document and i have been facing similar run-time error '5825' in Run-time and the Ribbon fades away. I have tried to load the .dotm module over Visual basic editor and ran the module and coudnt see any errors during debugging, but the word program closes abruptlly as error. Please can kindly help me to resolve this error.

  2. #2
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,334
    Location
    Are you losing the reference to your ribbon object?

    You might try some variation of this:

    Option Explicit
    #If VBA7 Then
      Public Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef destination As Any, ByRef source As Any, ByVal length As Long)
    #Else
      Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef destination As Any, ByRef source As Any, ByVal length As Long)
    #End If
    Public p_oRibbon As IRibbonUI
    Public Sub OnLoad(oRibbon As IRibbonUI)
      Set p_oRibbon = oRibbon
      ThisDocument.Variables("RXPointer") = ObjPtr(oRibbon)
      ThisDocument.Saved = True
    lbl_Exit:
      Exit Sub
    End Sub
    Function GetRibbon() As Object
    #If VBA7 Then
      Dim lngRibPtr As LongPtr
      lngRibPtr = CLngPtr(ThisDocument.Variables("RXPointer"))
    #Else
      Dim lngRibPtr As Long
      lngRibPtr = CLng(ThisDocument.Variables("RXPointer"))
    #End If
      Dim oRibbon As Object
      CopyMemory oRibbon, lngRibPtr, LenB(lngRibPtr)
      Set GetRibbon = oRibbon
      Set oRibbon = Nothing
    lbl_Exit:
      Exit Function
    End Function
    
    Sub AutoClose()
      ClearRibbonMemory
    lbl_Exit:
      Exit Sub
    End Sub
    
    Sub ClearRibbonMemory()
      Set p_oRibbon = Nothing
    lbl_Exit:
      Exit Sub
    End Sub
    
    Sub Test()
       If p_oRibbon Is Nothing Then Set p_oRibbon = GetRibbon
       p_oRibbon.InvalidateControl "G3EditBox001"
    End Sub
    Greg

    Visit my website: http://gregmaxey.com

  3. #3
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Cross-posted at: https://chandoo.org/forum/threads/er...deleted.45578/
    Please read VBA Express' policy on Cross-Posting in Rule 3: http://www.vbaexpress.com/forum/faq...._new_faq_item3
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  4. #4
    VBAX Newbie
    Joined
    Jan 2021
    Posts
    4
    Location
    Thank you Greg for your inputs.Yes, Ribbon referrnces fades aways and the VBA Error '5825' appears. While debugging the code, i could see the 'Object variable not set, 91 Error' for the object(see the attachment), not sure if this is the cause for Error '5825'. Please check and let me know the steps to post my .dotm code so you can verify and assist me.

  5. #5
    VBAX Newbie
    Joined
    Jan 2021
    Posts
    4
    Location
    Hi Greg,

    Good Day. With VBA Code at Design time, have been facing VBA Error '91' while debugging. But i am unable to figure out the exact line of code that causes the error. Please assist.

Posting Permissions

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