mir ist klar, LibreOffice ist **nicht** Excel! Nichtsdestotrotz haben sich die Entwickler offensichtlich sehr viel Mühe gegeben die Unterschiede zwischen Excel und Calc gering zu halten, viele Excel-Makros laufen einfach weiter als wäre nichts gewesen. Seit kurzem versuche ich Excel los zu werden und bin absolut neu was das LibreOffice Calc betrifft. OS = Win10. Das ist der Hintergrund.
Nun gibt es für Excel-Makros die Möglichkeit direkt auf die WinAPI zuzugreifen, zum Beispiel COM-Ports oder gar HID. Leider laufen die Excel-Makros beim Calc gar nicht (es hagelt mir nicht bekannte Fehlermeldungen und die Netzsuche bringt keine brauchbaren Funde).
- Kennt sich wer mit dem LibreOffice aus und hat wenigstens mal eine COM-Schnittstelle geöffnet bekommen?
Mein Code zur COM-Bedienung für Excel stammt von
Code: Alles auswählen
'-------------------------------------------------------------------------------
' modCOMM - Written by: David M. Hitchner
'
' This VB module is a collection of routines to perform serial port I/O without
' using the Microsoft Comm Control component. This module uses the Windows API
' to perform the overlapped I/O operations necessary for serial communications.
'
' The routine can handle up to 4 serial ports which are identified with a
' Port ID.
'
' All routines (with the exception of CommRead and CommWrite) return an error
' code or 0 if no error occurs. The routine CommGetError can be used to get
' the complete error message.
'-------------------------------------------------------------------------------
Code: Alles auswählen
Sub ComTest()
Dim intPortID As Integer ' Ex. 1, 2, 3, 4 for COM1 - COM4
Dim lngStatus As Long
Dim strError As String
Dim strData As String
Dim lngSize As Integer
Dim nowTick As Long
Dim endTick As Long
Dim reply As String
Dim replyLength As Integer
intPortID = Cells(2, 3).Value
' Initialize Communications
lngStatus = CommOpen(intPortID, "COM" & CStr(intPortID), _
"baud=19200 parity=N data=8 stop=1")
If lngStatus <> 0 Then
' Handle error.
lngStatus = CommGetError(strError)
MsgBox "COM Error: " & strError
Else
[...]
Code: Alles auswählen
LibreOffice 7.2.1.2
COM Error: Error (423): CommOpen - LastDllError
TeraTerm bedient die serielle Schnittstelle (hier COM4) problemfrei, das Gerät am anderen Ende des USB antwortet auch sehr brav.
Beim Experiment mit der HID-Klasse gibt es noch ganz anderen Ärger mit unstimmigen Tydefinitionen, das würde ich aber erst im zweiten Schritt angehen wollen. Erstmal soll die COM laufen.
- Ist das LibreOffice 7.2.1.2 Calc schon so weit, geht das (noch) gar nicht oder fehlt nur meinem recht frischen PC da etwas?
H.A.R.R.Y.