Hallo,

this is german list. If you can't read the following, please give a short 
notice and I'll send it in englisch.


Am Donnerstag, 30. November 2006 09:40 schrieb Guido H. Dirkes:
> Dear all,
>
> looks like I am to stupid for this. I tried the following code
>
> <code start>
> Sub Main
>       Dim Doc As Object
>       Dim Sheet As Object
>       Doc = StarDesktop.CurrentComponent
>       Sheet = Doc.Sheets(0)
>       If Doc.Sheets.hasByName("TestRack")
>       Then Sheet = Doc.Sheets.getByName("TestRack")
>       Else Sheet = Doc.createInstance("com.sun.star.sheet.Spreadsheet")
>               Doc.Sheets.insertByName("TestRack", Sheet)
>       End If
> End Sub
> <code end>
>
> and OpenOffice complains
> BASIC syntax error.
> unexpected: Then
Ich schreibe überlicherweise If  Bedingung Then in eine Zeile, dann klappt 
das. Den ganzen If Block in eine Zeile zu schreiben ist nicht nötig.

> When I change the code to so that I have all the line starting from If up
> to End If in one line than it complains about the
> Doc.Sheets.insertByName...
Was sagt OOo denn? Von wo startest Du das Makro? Falls Du es aus der IDE 
startest, zeigt StarDesktop.CurrentComponent möglicherweise nicht auf das 
Calc Document. Wechsle ins Calc Dokument und starte das Makro mit 
Extras->Makros->ausführen... Kommt der Fehler noch immer?
Es ist jedenfalls nichts grundsätzlich falsches daran, bei mir funktioniert 
es.
>
> This makes no sense at all to me....
wird hoffentlich noch :)

> I even started to think about changing to Excel, as VBA seems to be much
> more straight forward to use.
Ich fand das Objektmodell von OOo am Anfang auch schwieriger als das von MS 
Office. Alles eine Frage der Gewöhnung.

Warum hast Du die Zeile Sheet = Doc.Sheets(0) eigentlich? Du weisst Sheet 
später doch ein anderes Arbeitsblatt zu, ohne dass Du irgend etwas damit 
anstellst.

Liebe Grüße,
Verena
-- 
Open source.     Open mind.     Open future.
www.triosolutions.at [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Antwort per Email an