I have code performing actions in doc A and I would like to go to doc B, perform actions (based on info gathered from doc A), and get back to doc A in the same place. What would be the command for this?
Thanks,
When you use the command good it does not open a new view of the same documentptbento wrote:if the doc is already open, it opens a new one as a copy
As the second parameter, loadComponentFromURL expects a name for the frame object of the window that OpenOffice.org creates internally for its administration. The predefined _blank name is usually specified here, and this ensures that OpenOffice.org creates a new window.
sub openform2
dim sNewfileFormName
sNewfileFormName="file:///home/romgro/Documenten/opof/data/exampledata.ods"
'stardesktop.loadComponentFromURL(sNewfileFormName,"_blank",0,array()) ' _blank open a new view
stardesktop.loadComponentFromURL(sNewfileFormName,"_default",0,array()) ' sets focus to the document
end sub
RPG wrote:You cannot run macros stored in the document what is opened with Loadcomponentfromurl.
Romke
Sub RunMacroInAnotherDoc()
Dim thisDoc As Object
Dim otherDoc As Object
Dim Url As String
Dim Args(1) As new com.sun.star.beans.PropertyValue
Dim scriptProvider
Dim s
thisDoc = ThisComponent
Url = "otherDocUrl"
Args(0).Name = "MacroExecutionMode"
Args(0).Value = 4
Args(1).Name = "Hidden"
Args(1).Value = False
otherDoc = StarDesktop.loadComponentFromURL(Url, "_Blank", 0, Args)
Wait 1000
otherDoc.BasicLibraries.loadLibrary("Standard")
Wait 1000
Set scriptProvider = otherDoc.getScriptProvider()
s = scriptProvider.getScript("vnd.sun.star.script:Standard.Module1.SomeMacro?language=Basic&location=document")
s.invoke(array(), array(), array())
StarDesktop.setActiveFrame(otherDoc.CurrentController.Frame)
otherDoc.CurrentController.Frame.ContainerWindow.toFront()
Wait 5000
StarDesktop.setActiveFrame(thisDoc.CurrentController.Frame)
thisDoc.CurrentController.Frame.ContainerWindow.toFront()
End Sub
Edit: Above code modified since original post. In order to change into another document, you need the ContainerWindow.toFront() calls in addition to the setActiveFrame. |
Url = convertToURL("Full/path/to/document")
Doc1 = StarDesktop.loadComponentFromURL(Url, "_blank", 0, Dummy)
Url = convertToURL( "/Users/imac/Doc1.ods")
Return to OpenOffice Basic, Python, BeanShell, JavaScript
Users browsing this forum: No registered users and 6 guests