Domino 9 und frühere Versionen > ND7: Entwicklung

Schaltfläche: Exceldateien mit Calc öffnen

(1/2) > >>

Big768:
Hallo Ihr lieben Noteskolleginnen und -kollegen,

ich habe folgendes Problem und würde mich sehr freuen, wenn Ihr mir mal wieder helfen könnt:

Ich möchte mit einer Schaltfläche eine Exceldatei öffnen. In der Schaltfläche habe ich folgendes LS eingebaut:

   Dim workspace As New NotesUIWorkspace
   Dim uidoc As NotesUIDocument
   Dim thisDoc As NotesDocument
   Set uidoc = workspace.CurrentDocument
   Set thisDoc = workspace.CurrentDocument.Document
   Set x1=CreateObject("Excel.Application")
   x1.Application.Workbooks.Open thisdoc.Exceldatei
   x1.application.visible=True

Wobei die Variable Exceldatei den Pfad und die Datei enthält.

Ist auf dem Rechner Excel installiert funktioniert das alles wunderbar. :)

Ist auf dem Rechner aber OpenOffice installiert und kein Excel erhalte ich die Fehlermeldung:
"Cannot create automationobject".

Ist ja auch klar. Er soll ja auch konkret Excel öffnen.  Kann ich dort irgendeinen Befehl eingeben, dass er Calc nimmt, wenn Excel nicht installiert ist?  ???

Im voraus vielen Dank für Eure Hilfe.

Johann

m3:
OO.org musst Du ähnlich aber anders ansprechen (UNO via COM). Da hilft nur eine If-Bedingung.

Big768:
Hallo m3,

erstmal vielen Dank für die schnelle Antwort.

Ich bin jetzt etwas weitergekommen. Mit

   Set SM=CreateObject("com.sun.star.ServiceManager")
   Set Desktop=SM.createInstance("com.sun.star.frame.Desktop")
   Dim args()
   Set CalcApplication=Desktop.loadComponentFromURL("private:factory/scalc","_blank",0,args)

kann ich eine leere Tabelle in Calc öffnen.  :)

Ich möchte aber keine neue leere Tabelle öffnen, sondern eine bereits bestehende.  ???

Hat vielleicht noch einer einen Tip?

Vielen Dank im voraus.

Johann

m3:

--- Zitat ---The loadComponentFromURL() method of the Desktop object can open a document. To do so, you must pass the URL of a document. In OOo Basic, here is an example...

--- Code: ---oDoc = StarDesktop.loadComponentFromURL( "file:///home/danny/Desktop/MyDoc.sxd", "_blank", 0, Array() )
--- Ende Code ---

--- Ende Zitat ---

Open and Create documents, various prog. languages

(man beachte die URL, die geöffnet wird)

Axel:
Ich würde das in etwa so machen. Leider weiss ich den ErrorCode in Err nicht, der auftritt wenn Excel nicht instanziert werden kann. Musst du mal testen und dann xxx durch den Code ersetzen

   Dim workspace As New NotesUIWorkspace
   Dim uidoc As NotesUIDocument
   Dim thisDoc As NotesDocument
   Dim x1 As Variant

   Set uidoc = workspace.CurrentDocument
   Set thisDoc = workspace.CurrentDocument.Document

   On Error Resume Next

   Set x1=CreateObject("Excel.Application")
   If Err = ??? Then  '  Fehler tritt auf wenn Excel nicht installiert
     Err = 0
     ' Hier wird dann Calc angesprochen
     ...
   Else
     x1.Application.Workbooks.Open thisdoc.Exceldatei
     x1.application.visible=True
     ...
   End If

Das Thema OpenOffice hatten wir hier auch schon ein paarmal, u.a. hier http://atnotes.de/index.php/topic,43334.0.html.

Vielleicht bringt dich das weiter.

Axel

Navigation

[0] Themen-Index

[#] Nächste Seite

Zur normalen Ansicht wechseln