Apache OpenOffice (AOO) Bugzilla – Issue 74657
oDesktop.LoadComponentFromURL causes error in macro
Last modified: 2013-02-24 21:08:46 UTC
Hi, when I'm running the following macro on my machine it causes an error in the line "oDocument = oDesktop.LoadComponentFromURL(sUrl,"_blank",0,mNoArgs)" saying: "BASIC Laufzeitfehler. Objektvariable nicht belegt". I am using openOffice.org 2.1 on Windows XP, SP2. The same macro on the same machine runs fine when I call it in openOffice.org 1.0.1. It opens a new openOffice.org - document... Calling the repair option from the installation makes no difference. Allthough it would not say so in the Help Menu I think I am using the latest version of openOffice.org available in german. Thanks for your attention sub test oDesktop = createUnoService("com.sun.star.frame.Desktop") sUrl = "staroffice.factory:swriter" oDocument = oDesktop.LoadComponentFromURL(sUrl,"_blank",0,mNoArgs) oText = oDocument.Text oText.setString("") oCursor = oText.createTextCursor() end sub
Created attachment 43164 [details] document containing the macor named 'test'
Created attachment 43165 [details] error dialog
I can confirm that current versions (2.1 and 2.2m7) produce an error message, but 1.0.3 and 1.1.5 display the same error message too. As I do not know where I can download 1.0.1 I can't test that.
For your information, This macro is probably coming from StarOffice 5, and uses obsolete code. OpenOffice is not fully compatible with StarOffice 5, and OOo 1.0.1 is no longer supported. First error : variable mNoArgs must be defined as an array (empty array in your case) dim mNoArgs() Second error : the url for creating a new writer document is incorrect. It should be sUrl = "private:factory/swriter" And final remark: OpenOffice Basic provides a convenient StarDesktop. Corrected code : dim mNoArgs() sUrl = "private:factory/swriter" oDocument = StarDesktop.LoadComponentFromURL(sUrl,"_blank",0,mNoArgs) oText = oDocument.Text oText.setString("") oCursor = oText.createTextCursor() Please use existing forums or mailing lists for further help, e.g. http:// www.oooforum.org/
Thank you for your information and the corrected code. The macor works well. I must have been using an outdated Sun Programmer's Giude.
invalid
closed