Custom buttons

Do you want to: Ask a how-to question
Document Server version: OnlyOffice 8.0.1.31
OS: Window Server 2022
Browser version:Chrome

Hi
I would like to add custom buttons to OnlyOffice Editor or add plugin to OnlyOffice.
Buttons should by call custom function witch return text and put in in selected area.

In MS Word i using macros to made this operation. How can i do this in OnlyOffice?

Hello @Michal

Please provide your macros for reference.

Hi
Below is sample code. Code create menu bar ‘MenuBar’ with buttons. After click menu bar button “NrSprawy” is call function NrSprawy() whith put text in selected text.
Function ‘Narzedzia()’ is create menu. Is called after load document.
Is any way to do this in Only Office using macros or plugin and put macros from codebehind using config or javascript before document loaded

Dim bar As CommandBar
Dim menu As CommandBarPopup


Public Sub NrSprawy()
Selection.TypeText "<el:nr_sprawy />"
End Sub


Private Sub Narzedzia()
Set bar = CommandBars.Add("MenuBar", MsoBarPosition.msoBarTop, False, True)
Set menu = CommandBars("Menu Bar").Controls.Add(Type:=msoControlPopup, Temporary:=True)
menu.caption = "MenuBar"
PozycjaNarzedzi "Numer sprawy", "Znacznik <el:nr_sprawy />", "NrSprawy", "picture.bmp", "picture.bmp"
bar.Visible = True
End Sub

Private Sub PozycjaNarzedzi(caption As String, toolTip As String, onAction As String, rys As String, msk As String)
Dim butt As CommandBarButton
Dim rysunek As IPictureDisp
Dim maska As IPictureDisp
Set rysunek = stdole.StdFunctions.LoadPicture(rys)
Set maska = stdole.StdFunctions.LoadPicture(msk)
Set butt = bar.Controls.Add(MsoControlType.msoControlButton)
butt.caption = caption
butt.TooltipText = toolTip
butt.onAction = onAction
butt.Picture = rysunek
butt.Mask = maska
Set butt = menu.Controls.Add(MsoControlType.msoControlButton)
butt.caption = caption
butt.TooltipText = toolTip
butt.onAction = onAction
butt.Picture = rysunek
butt.Mask = maska
End Sub

obraz

Hello @Michal
If you don’t mind, I will step to this thread too.

Unfortunately, there’s no way to add custom buttons in the editor toolbar right now. We are working on this feature and I will add your request to tracklist.
As for the situation in general. From my point of view, you need to create a plugin for such scenario or try to convert your macro code to js: ONLYOFFICE Api Documentation - Converting MS VBA macros
For plugins, I believe these titles will be useful:
ONLYOFFICE Api Documentation - Overview - general information
ONLYOFFICE Api Documentation - InputText - input text to a file method
ONLYOFFICE Api Documentation - Plugin examples - probably it is useful as an example of modal window creation that you can use instead of pop-up ‘bar’ menu.

Hi

Thanks to replay. I will try to convert to js or create to custom plugin.