Issue 74657 - oDesktop.LoadComponentFromURL causes error in macro
Summary: oDesktop.LoadComponentFromURL causes error in macro
Status: CLOSED NOT_AN_OOO_ISSUE
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All Windows XP
: P3 Trivial
Target Milestone: ---
Assignee: jsc
QA Contact: issues@api
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-19 12:37 UTC by schmieta
Modified: 2013-02-24 21:08 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
document containing the macor named 'test' (7.44 KB, application/vnd.oasis.opendocument.text)
2007-02-19 12:38 UTC, schmieta
no flags Details
error dialog (4.42 KB, image/gif)
2007-02-19 12:39 UTC, schmieta
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description schmieta 2007-02-19 12:37:36 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
Comment 1 schmieta 2007-02-19 12:38:47 UTC
Created attachment 43164 [details]
document containing the macor named 'test'
Comment 2 schmieta 2007-02-19 12:39:35 UTC
Created attachment 43165 [details]
error dialog
Comment 3 kpalagin 2007-02-19 15:58:21 UTC
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.
Comment 4 bmarcelly 2007-02-19 20:30:26 UTC
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/
Comment 5 schmieta 2007-02-21 11:51:01 UTC
Thank you for your information and the corrected code.
The macor works well.
I must have been using an outdated Sun Programmer's Giude.

Comment 6 jsc 2007-02-28 10:11:37 UTC
invalid
Comment 7 jsc 2007-02-28 10:12:05 UTC
closed