From my main document “CreateBookmarks” my macro code creates a new document based on a template “Bookmarks” that contains several bookmarks. I am having difficulties referring to these bookmarks.
Here is my test code contained in “CreateBookmarks”:
Sub CreateBookmarkDoc
Dim sURL as String
Const sPathName = "F:\Users\ifsian\Documents\OpenOffice\Templates\Bookmarks.ott"
sURL = ConvertToURL(sPathName)
StarDesktop.loadComponentFromURL(sURL,0,"_default",Array())
msgbox "Bookmark Count: " & ThisComponent.getBookmarks().getcount()
End Sub
When executed in the original document, ThisComponent.getBookmarks().getcount() returns 0. If the above code is copied into a module under MyMacros and Dialogs and executed it works. A new document is created and the count of bookmarks in the document just created returned. I am guessing ThisComponent.getBookmarks().getcount() is counting bookmarks in the original document rather than the document just created even though this document has focus.
My question is:
What is the correct syntax to access bookmarks in another document?
Edited format of code block. mark_t