"Runtime variable not set"

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
ouroborus
Posts: 3
Joined: Tue Nov 18, 2008 4:21 pm

"Runtime variable not set"

Post by ouroborus »

I have a document that I'm trying to reformat. Part of that is reformatting all the embedded objects. I'm trying to use a BASIC macro to do this but I'm getting a strange error. Here's a stripped down version of the macro:

Code: Select all

Sub Test
	Dim objects As Object
	Dim obj As Object
	Dim embedded As Object
	Dim test As String
	
	objects = ThisComponent.getEmbeddedObjects()
	
	For i = 0 to objects.count-1
		obj = objects(i)
		embedded = obj.getEmbeddedObject()

		If embedded.supportsService("com.sun.star.formula.FormulaProperties") Then
			' fails on the previous line when i reaches 20

			' only fails if you've been writing to the objects' children:
			test = embedded.Formula
			embedded.Formula = test
		End If
	Next i
End Sub
The error occurs when i reaches 20. (There are over 90 embedded objects in the document.) It seems similar to the unsolved problem A in this thread.

What am I doing wrong?
OOo 3.0.X on Ms Windows XP
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: "Runtime variable not set"

Post by Villeroy »

I'm not shure, but something is looking strange. You loop through the collection of embedded objects ...

Code: Select all

objects = ThisComponent.getEmbeddedObjects()
For i = 0 to objects.count-1
... and then you get another embedded object from the member of the collection:

Code: Select all

obj = objects(i)
embedded = obj.getEmbeddedObject()
Symbol "embedded" is not a member of the the original collection "objects".
You do use the Xray tool, don't you?
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
ouroborus
Posts: 3
Joined: Tue Nov 18, 2008 4:21 pm

Re: "Runtime variable not set"

Post by ouroborus »

Villeroy wrote:I'm not shure, but something is looking strange. You loop through the collection of embedded objects ...

Code: Select all

objects = ThisComponent.getEmbeddedObjects()
For i = 0 to objects.count-1
... and then you get another embedded object from the member of the collection:

Code: Select all

obj = objects(i)
embedded = obj.getEmbeddedObject()
Symbol "embedded" is not a member of the the original collection "objects".
Is there perhaps an approved way of accomplishing this?
Villeroy wrote:You do use the Xray tool, don't you?
No, but I'll look into it.

[UPDATE] I installed Xray and messed around with it a bit.

Seems that when getEmbeddedObject() is called on the 21st object (i=20), the system hangs for around 1-5 seconds, then returns an incomplete object.

It seems as if it's trying to duplicate the object somehow before returning it, decides it takes to long, returns it anyway and tries to finish up the duplication hoping the object won't be accessed right away. Sounds weird, I know.

Depending on how fast the 'embedded' variable is accessed, it'll be a Null object or (very rarely) what appears to be an incomplete object as shown by Xray:

Code: Select all

Alignment                 integer                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
BaseFontHeight            integer                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
BasicLibraries            object                           read-only, <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
BottomMargin              integer                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
CustomFontNameFixed       string                           <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
CustomFontNameSans        string                           <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
CustomFontNameSerif       string                           <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
DialogLibraries           object                           read-only, <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
FontFixedIsBold           boolean                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
FontFixedIsItalic         boolean                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
FontFunctionsIsBold       boolean                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
FontFunctionsIsItalic     boolean                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
FontNameFunctions         string                           <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
FontNameNumbers           string                           <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
FontNameText              string                           <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
FontNameVariables         string                           <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
FontNumbersIsBold         boolean                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
FontNumbersIsItalic       boolean                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
FontSansIsBold            boolean                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
FontSansIsItalic          boolean                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
FontSerifIsBold           boolean                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
FontSerifIsItalic         boolean                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
FontTextIsBold            boolean                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
FontTextIsItalic          boolean                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
FontVariablesIsBold       boolean                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
FontVariablesIsItalic     boolean                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
Formula                   string                           <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
IsScaleAllBrackets        boolean                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
IsTextMode                boolean                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
LeftMargin                integer                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
LoadReadonly              boolean                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
PrinterName               string                           <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
PrinterSetup              []byte                           <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeBracketDistance   integer                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeBracketExcessSize integer                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeFontHeightFunctions integer                        <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeFontHeightIndices integer                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeFontHeightLimits  integer                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeFontHeightOperators integer                        <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeFontHeightText    integer                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeFractionBarExcessLength integer                    <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeFractionBarLineWeight integer                      <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeFractionDenominatorDepth integer                   <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeFractionNumeratorHeight integer                    <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeIndexSubscript    integer                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeIndexSuperscript  integer                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeLineSpacing       integer                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeLowerLimitDistance integer                         <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeMatrixColumnSpacing integer                        <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeMatrixLineSpacing integer                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeOperatorExcessSize integer                         <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeOperatorSpacing   integer                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeRootSpacing       integer                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeScaleBracketExcessSize integer                     <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeSpacing           integer                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeSymbolMinimumHeight integer                        <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeSymbolPrimaryHeight integer                        <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RelativeUpperLimitDistance integer                         <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RightMargin               integer                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
RuntimeUID                string                           read-only, <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
Symbols                   []struct                         <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
TopMargin                 integer                          <An exception occurred 
Type: com.sun.star.beans.UnknownPropertyException
Message: .> 
Parent                    object                           pseudo-prop 
DocumentInfo              object                           pseudo-prop, read-only 
DocumentProperties        object                           pseudo-prop, read-only 
Events                    object                           pseudo-prop, read-only 
AllowMacroExecution       boolean                          attribute, read-only 
ScriptContainer           object                           attribute, read-only 
URL                       string                           pseudo-prop, read-only 
Args                      []struct                         pseudo-prop, read-only 
CurrentController         object                           pseudo-prop 
CurrentSelection          object                           pseudo-prop, read-only 
Controllers               object                   <null>  pseudo-prop, read-only 
AvailableViewControllerNames []string             <empty>  pseudo-prop, read-only 
Modified                  boolean                          pseudo-prop, write-only 
Printer                   []struct                         pseudo-prop 
Location                  string                           pseudo-prop, read-only 
LibraryContainer          object                           pseudo-prop, read-only 
ViewData                  object                           pseudo-prop 
TransferDataFlavors       []struct                         pseudo-prop, read-only 
DocumentSubStoragesNames  []string                         pseudo-prop, read-only 
DocumentStorage           object                           pseudo-prop, read-only 
ScriptProvider            object                           pseudo-prop, read-only 
UIConfigurationManager    object                           pseudo-prop, read-only 
Identifier                string                       ""  pseudo-prop 
Title                     string                       ""  pseudo-prop 
UntitledPrefix            string                       ""  pseudo-prop, read-only 
Types                     []type                           pseudo-prop, read-only 
ImplementationId          []byte                           pseudo-prop, read-only 
ImplementationName        string                    <...>  pseudo-prop, read-only 
SupportedServiceNames     []string                         pseudo-prop, read-only 
PropertySetInfo           object                           pseudo-prop, read-only 
Dbg_Properties            string                    <...>  basic prop, read-only 
Dbg_Methods               string                    <...>  basic prop, read-only 
Dbg_SupportedInterfaces   string                    <...>  basic prop, read-only 
It seems possible to make things work it there's a forced pause (waiting a while before clicking Xray's Close button) between access of the 20th and 21st objects. The same seems to be true for every increment of 20, but it's harder to get it to die on the later ones.
OOo 3.0.X on Ms Windows XP
ouroborus
Posts: 3
Joined: Tue Nov 18, 2008 4:21 pm

Re: "Runtime variable not set"

Post by ouroborus »

I was running OOo 3.0.0. I switch to 2.4.2 and the script works fine there. So I guess it's an issue with 3.0.0. I also noticed that 3.0.0 is a *lot* slower.
Post Reply