Hi - Below are two examples: test with shortcut and with the name.
Adapt the Category name and Shortcut to the interface language.
These procedures return either #N/A if the AutoText is not found or the text. Regards.
option explicit
sub main
msgbox PysAutoTextByShortCut("standard", "AR"), 64, "AutoText"
msgbox PysAutoTextByName("standard", "Acknowledgement of Receipt"), 64, "AutoText"
end sub
function PysAutoTextByName(sCat as string, sName as string) as string
dim oAutoTextContainer as object, oGroup as object, oEntry as object, i as integer
oAutoTextContainer = CreateUnoService("com.sun.star.text.AutoTextContainer")
PysAutoTextByName = "#N/A"
if oAutoTextContainer.hasByName(sCat) then
oGroup = oAutoTextContainer.getByName(sCat)
for i = 0 to ubound(oGroup.Titles)
if oGroup.Titles(i) = sName then
oEntry = oGroup.getByIndex(i)
PysAutoTextByName = oEntry.string
exit for
end if
next i
end if
end function
function PysAutoTextByShortCut(sCat as string, sSC as string) as string
dim oAutoTextContainer as object, oGroup as object, oEntry as object
oAutoTextContainer = CreateUnoService("com.sun.star.text.AutoTextContainer")
PysAutoTextByShortCut = "#N/A"
if oAutoTextContainer.hasByName(sCat) then
oGroup = oAutoTextContainer.getByName(sCat)
if oGroup.hasByName(sSC) then
oentry = oGroup.getByName(sSC)
PysAutoTextByShortCut = oEntry.string
end if
end if
end function