How reloading file in floating frame via star basic?

How can you reload a linked file in a floating frame via macro?
Manually there is no problem, but I can’t record it with the macro recorder

edit 20 jan

From the tests I have performed, inserting a single floating frame in a writer document associating it to any file, the following first code

   f = thisComponent.embeddedObjects
   f0 = f.getByIndex (0):
   f1 = f0.embeddedObject.component

Accesses its properties, including URLFrame. Unfortunately modifying URLFrame to force the frame reload doesn’t force anything.

Debugging the IDE macro, executing the code step by step, signals to me that f1 supports the service of which I cannot find any documentation

It also reports an implementationName = of which I cannot find documentation

In the same file, this second code.

 dim d, document, dispatcher, f, f0
  d = ThisComponent
  document = d.CurrentController.Frame
  dispatcher = createUnoService ("")

   f = d.embeddedObjects: f0 = f.getByIndex (0): (f0)
  dim args2 (0) as new
  args2 (0) .Name = "VerbID": args2 (0) .Value = -7

  dispatcher.executeDispatch (document, ".uno: ObjectMenue", "", 0, args2 ())

executed manually twice in succession it manages to open the contextual menu of the frame. Just a click on OK to force the reload.

Can anyone explain to me why it must be done twice and how can I force the ok macro without typing it manually?

Is it possible that you cannot create a floating frame not linked to an external file to be accessed with a macro to modify its content?

In other embeddedObject (see [Solved] A macro to access an embedded text document (View topic) • Apache OpenOffice Community Forum ) is possible

Other link How reloading file in floating frame via star basic? (see final part of the code)

HERE the tests files

Since I recently had first time to do a bit with ole objects, I was interested and spent some time with investigations concerning your question. I couldn’t find a way to update the floating frame’s component according to the newly set FrameURL without saving and reloading the complete document.
Pleas tell if you eventually find one.

I attach these 3 links, they can be useful and the test files and img used (ask.libreoffice do not accept zip and i don’t know how attach more than one file)

How to remove a word from all formulas in a .odt file (see Sub refreshOleObject)

In the test files, ggFF0 file contains the floating frame (FF) and a section (sect1). The ggFFSrc file is linked to the FF, and contains a section linked to sect1.

Both macros if executed manually (two consecutive calls executed by macros do not seem to have the same effect) twice in a row they open a form of parameters which, by clicking on “OK”, update the frame without having to save the document that contains it

The need to have to launch them manually makes me think that it takes some time to settle, perhaps the first time the process is closed before it ends.

Furthermore, when opening ggFF0 the frame is NOT activated (see img01). Activating the context menu manually or from macro by launching it twice, after selecting the frame (see img2) with click on OK it is activated.
Just understand why two manual calls and how to give the OK automatically and the problem is solved, I think

In some tests, the obligation to manually twice run the macro I mentioned previously only exists the first time, when you open the ggFF0 file the first time

Subsequent reloads apparently only require one call, not two

The problem remains of how, once the form is opened via macro, it can be closed automatically and not manually

My comment above containing “found now ways…” should be read with a "… without requiring user interaction…

I think the solution is very close, to anyone who wants to contribute I try to add additional information as I find it, it may be easier for someone to have the final idea that I am missing

Specifically, what is missing is how to provide the final OK automatically, it should be a common problem with other dialog boxes opened from the libreoffice menus

Here libreoffice-core/insdlg.cxx at master · KDAB/libreoffice-core · GitHub java code using properties FrameURL, ecc

Why didn’t you attach the test files the regular way? I won’t go “study google drive” for this one occasion.

While this answer is almost complete, the final step is still missing.

Compared to the previous comments, the procedure has been much simplified (the dispatcher is no longer used) after having understood something more about the embeddedObject.

Unfortunately, the online documentation on the use of macros with star basic is extremely limited. There is more in Java, a language that I don’t know.

In the ggFF0 file of which I had provided the link at the end of the initial question, all the macros must be deleted and replaced with the following two (ffInit and ffRefresh)

The ffInit should only be run once when opening ggFF0, for example by placing it in an event handler associated with opening the document.
Its execution automatically displays (and not manually as before) the current content of the ggFFSrc file in the frame

The sub ffRefresh () must be performed every time the reload of the ggFFSrc file is requested. The frame specific properties window opens, just click OK (or type return) to close it and the reload automatically takes place.

It’s annoying to have this extra manually step, even if the rest of the procedure is completely automated, including opening the menu.
For my purposes it is tolerable, in other situations less tolerable

 sub ffInit ()
       dim d as object, embOBs as object, or as object, oExt as object
       d = ThisComponent
       embOBs = d.embeddedObjects
            ' or other index used, or name with getByName, can be a sub parameter
       o = embOBs.getByIndex (0)  
       oExt = o.ExtendedControlOverEmbeddedObject
       oExt.doVerb (-5)
    end sub
    sub ffRefresh ()
       dim d as object, embOBs as object, or as object, oExt as object
       d = ThisComponent
       embOBs = d.embeddedObjects
       o = embOBs.getByIndex (0)
       oExt = o.ExtendedControlOverEmbeddedObject
       oExtCmp = oExt.component
       oExt.doVerb (-7) 'alternative: oRes = oExtCmp.execute ()
    end sub

It is useless to simulate pressing the return key the instruction following the opening of the dialog box of the frame properties because it is performed only after the manual click on the OK button of the dialog

Load method of XFrameLoader (Interface XFrameLoader) can be a solution, but I don’t understand how to set the two parameters it requires on input

As I understand more about embeddedObject and frames I will update this answer. Any contribution is clearly appreciated.

Edit 22 jan; my parzial solution is surpassed by that of Ratslinger who, on the contrary, completely solves the problem.

A more optimized solution can be the following:

sub ffRefresh (opId, idx)
   dim d as object, embOBs as object, or as object, oExt as object
   d = ThisComponent
   embOBs = d.embeddedObjects
   o = embOBs.getByIndex (idx)
   oExt = o.ExtendedControlOverEmbeddedObject
   oExtCmp = oExt.component   ' for now, only per alternative open dialog 
                          ' or other operation   with oExtCmp
   if opid=0 then 
         oExt.doVerb (-5)
         oExt.doVerb (-7) '  alternative: oRes = oExtCmp.execute ()
   end if
end sub

First time, call this sub with opId=0, for reload, call with opId <> 0


Have fooled around with this since your original post. Don’t know why you need to call the routine twice as I don’t have that problem. Works first time every time.

Regardless, have finally (by random testing) found the solution. Once you have your extended object (in your code oExt) add the following lines:


Had no problem with multiple floating frames. Just access the one you want to update. Access was no problem with getByIndex (as you have) or getByName.

Should be known that updated data reflects only what is saved in linked document. Have tested with both a simple text document and .odt document.

I guess I should also say to remove your other doVerb() lines.

It works perfectly !! I didn’t know what to try anymore. There is really nothing on the net about how to reload the floating frame. Very thanks.

One last curiosity: in the refreshing operation I thought that working with thisComponent.lockControllers () before and with ThisComponent.unlockControllers () would have eliminated the flicker due to the operation. I see that instead it remains.

It is not a problem, it is enough for me that your very simple solution works.
To my knowledge, I’d like to understand why the flicker remains. This is the code I use now with your solution



PS: as an Italian, with little knowledge of English, I help myself a lot with google translate, I have not completely understood the meaning of the first line of your post (… Have fooled around with this since your original post … )

Unfortunately don’t have an immediate response to the “flicker”. Head needs to be cleared from this before trying to look into something I know nothing about - again!

Contrary to your concern, I am more curious as to what each state actually does. 0 (zero) seems to wipe out the link. 3 is normal. We know 1 works here but what does each actually stand for? There are five numbered 0-4.

… Have fooled around with this since your original post …

Meaning to randomly trying different things without real direction. I also have used Google translate and not always certain it is what I actually mean.

Edit: Flicker is gone for me when I apply the locking of the controller. Using Ubuntu 18.04 Mate with LO v6.3.4.2

Until a week ago I had no idea how to use OLE via macro. It is a fairly complex topic, knowing little about the internal frame structure and the libreoffice philosophy.
Libreoffice (applications and macros) I have been studying them for about six months, I still have a lot to learn. I too am interested in understanding more on libreoffice for next macro to be made

For this I went by trial and error, starting with the dispatcher and working a lot with debugging the IDE macro by examining all the properties and methods of the object hierarchy.
The macro recorder helps little or nothing in this.

From debugging I discovered the existence of verbs and from a couple of examples found on the net I understood how to activate the OLE in place (doVerb (-5)) and how to open the menu (doVerb (-7))
In these days, studying, I orient myself a little more,

The embedStates (LibreOffice: com::sun::star::embed::EmbedStates Constant Group Reference) I still have to investigate them, I have given priority to the verb.
From your edit i see flicker is gone. How is your flicker avoidance code different from mine ? (see next line)



I use Ubuntu 16.04 and libreoffice

Thanks for the link. My code(basically the same):


oXEO = oExt

Also, most of my discoveries are made using MRI. That is how I was able to solve this one. Have done a bit with OLE myself especially in the area of Charts (in Base and Writer).

Not certain I agree with the link information. With changeState(0) the link is GONE and must be re-established. This is what lead me to look at the other possibilities.

Flicker note: on my system gtk3 is used. May have something to do with this.

Fixed the problem of flickering. I ran the macro from the ide. Running the macro from my user toolbar works perfectly without flickering.
It helped me know that it worked for you

I tried MRI today for the first time, but I get this installation error:

( {{Message = "<class ‘SyntaxError’>: invalid syntax (, line 21), traceback follows \ X000a File " / usr / lib / libreoffice / program / \ ", line 149, in writeRegistryInfo \ X000a mod = self.getModuleFromUrl (locationUrl) \ X000a File " / usr / lib / libreoffice / program / \ ", line 102, in getModuleFromUrl \ X000a codeobject = compile (src, encfile (filename), \ "exec ") \ X000a \ X000a ", Context = ( @ 0}}

Maybe I have to uninstall and reinstall libreoffice

The problem you found on the official libreoffice documentation on the official channels should be reported.

I also attach these other links:

Try MRI from this site:

Releases · hanya/MRI · GitHub

I am using v1.3.4