I just tried to adapt for Word, the Excel code that Guessed proposes in the link.
However, I have a problem, Word crashes at the line :
CopyMemory myRibbon, lRibbonPointer, LenB(lRibbonPointer) in the Function GetRibbon(...)
The application crashes, then restarts the recovered document in read-only mode.
Here are the lines I modified to adapt them to Word
I added in declaration :
Private Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As LongPtr)
Then in: Sub RibbonLoaded_MyCustomAddin(ribbon As IRibbonUI)
I replaced : ThisWorkbook.Names.Add Name:="RibbonID", RefersTo:=StoreRibbonPointer
with : ThisDocument.Variables("RibbonID") = StoreRibbonPointer
in : Sub RefreshRibbon()
I replaced: Set objRibbon = GetRibbon(Replace(ThisWorkbook.Names("TSGRibbonID" ).RefersTo, "=", ""))
by : Set objRibbon = GetRibbon(Replace(ActiveDocument.Variables("Ribbon ID"), "=", ""))
Does anyone have the skills to help me? Here I am sinking
Sincerely,
David
|