Select Whole Writer Document

Creating Extension - Shared Libraries
Forum rules
For sharing working examples of macros / scripts. These can be in any script language supported by [Basic, Python, Netbean] or as source code files in Java or C# even - but requires the actual source code listing. This forum is not for asking questions about writing your own macros.

Select Whole Writer Document

Postby JeJe » Sun Feb 03, 2019 9:49 pm

There is a problem with a table at the start of the document - its necessary to add a paragraph if so.

see viewtopic.php?f=7&t=59825

Code: Select all   Expand viewCollapse view
sub test()
   dim AddedParaAtStart as boolean
   msgbox AddedParaAtStart
end sub

Sub SelectWholeWriterDocument(Doc,byref AddedParaAtStart as boolean)
   dim dispatcher as object,OVC
   oText= doc.text
   OVC =thiscomponent.currentcontroller.viewcursor ' oText.createTextCursorByRange(oText.getStart)
   with oVC
      do until res = false
         res =.goUp(1,false)
      if Not IsEmpty(.TextTable) then 'if table at start then need to insertparagraph
         'Text.insertControlCharacter(oVC,, false) DOESN'T DO THIS
         dispatcher = createUnoService("")
         dispatcher.executeDispatch(Doc.CurrentController.Frame, ".uno:InsertPara", "", 0, Array())
         AddedParaAtStart = true
      end if
   end with
End Sub

Edit:fixed calling name of sub in Test function
Openoffice 4.1.6
Windows 8
Posts: 1410
Joined: Wed Mar 09, 2016 2:40 pm

Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 1 guest