Using Frames led us up a blind alley!
I have made progress! After numerous Google searches and consulting Andrew Pitonyak’s excellent reference Open Office Macros Explained, I have reached this point:
GlobalScope.BasicLibraries.LoadLibrary("Tools") 'Contains FileNameOutOfPath
vComponents = StarDesktop.getComponents() 'Get all the components
vDocs = vComponents.createEnumeration() 'Enumerate them
Do While vDocs.hasMoreElements() 'While there are more
vDoc = vDocs.nextElement() 'Get the next component
If vDoc.SupportsService("com.sun.star.text.TextDocument") Then
if vDoc.GetBookmarks().GetCount <> 0 then
vBookmarks = vDoc.GetBookmarks()
for i = 0 to vBookmarks.getCount() -1
vBM = vBookmarks.getbyIndex(i)
vBM.getAnchor.setString("(" & Now() & ": " & vBM.Name & ")")
This code loops through my open documents, finds all bookmarks and inserts text at those bookmarks. My next challenge is manipulating tables in the documents.
During this process I came across numerous comments from others about how poorly the Object model is documented. The most frustrating aspect is no consistency. EG: using .createEnumeration() works in some places but not others. One commentor made the observation that a big issue holding Open Office/Libre Office back in the commercial world is the very steep learning curve for OO/LO Basic vs MS Office VBA. I agree. I have written numerous macros in MS VBA. In the VBA object browser you can inspect any object to determine the correct syntax.