von eBayer » Mo, 06.04.2009 16:25
So kannst Du auf die Felder Deines Formulars per Makro zugreifen:
Sub Senden
Dim oDoc As Object. oForm As Object, oControl As Object, sText1 As String, sText2 As String, sReturn As String
oDoc = thisComponent
oForm = oDoc.drawpage.forms.getbyindex(0) ' gibt Dir Dein aktuelles Formular als Object
oControl = oForm.getByName("Feldname1") ' gibt Dir Das entsprechende Eingabefeld des Formulars als Object
sText1 = oControl.text ' gibt Dir den Inhalt (Text) vom Object oControl
oControl = oForm.getByName("Feldname2") ' gibt Dir Das entsprechende Eingabefeld des Formulars als Object
sText2 = oControl.text ' gibt Dir den Inhalt (Text) vom Object oControl
msgbox sText ' und so kannst Du den Text zu Testzwecken anzeigen. Ist natürlich im normalen Ablauf nicht notwendig.
' Nun brauchst Du doch nur sText nach Com übertragen....
sReturn = Senden2Com(sText1, sText2)
msgbox sReturn
End Sub
Function Senden2Com(sOut1, sOut2)
Dim sendstr As string, oObj As Object, Dim a
oObj = createUnoService("org.openoffice.comp.rsapi")
oObj.setdevice("COM1")
sendstr = ("*G1$C1$T") 'vorbelegung
sendstr = sendstr & sOut1
sendstr = sendstr & ("$F")
sendstr = sendstr & sOut2
sendstr = sendstr & chr(10)&chr(13)
oObj.opencom("9600,8,2")
a = oObj.rts(1)
oObj.sendstring(sendstr)
oObj.closecom()
' Falls Fehler an Senden zurückgemeldet werden soll kannst Du das hier machen:
Senden2Com = "meine Fehlermeldung"
End Function
Etwas umständlich, aber so besser nachzuvollziehen.
Hilft Dir das weiter?
Gruß eBayer
So kannst Du auf die Felder Deines Formulars per Makro zugreifen:
Sub Senden
Dim oDoc As Object. oForm As Object, oControl As Object, sText1 As String, sText2 As String, sReturn As String
oDoc = thisComponent
oForm = oDoc.drawpage.forms.getbyindex(0) ' gibt Dir Dein aktuelles Formular als Object
oControl = oForm.getByName("Feldname1") ' gibt Dir Das entsprechende Eingabefeld des Formulars als Object
sText1 = oControl.text ' gibt Dir den Inhalt (Text) vom Object oControl
oControl = oForm.getByName("Feldname2") ' gibt Dir Das entsprechende Eingabefeld des Formulars als Object
sText2 = oControl.text ' gibt Dir den Inhalt (Text) vom Object oControl
msgbox sText ' und so kannst Du den Text zu Testzwecken anzeigen. Ist natürlich im normalen Ablauf nicht notwendig.
' Nun brauchst Du doch nur sText nach Com übertragen....
sReturn = Senden2Com(sText1, sText2)
msgbox sReturn
End Sub
Function Senden2Com(sOut1, sOut2)
Dim sendstr As string, oObj As Object, Dim a
oObj = createUnoService("org.openoffice.comp.rsapi")
oObj.setdevice("COM1")
sendstr = ("*G1$C1$T") 'vorbelegung
sendstr = sendstr & sOut1
sendstr = sendstr & ("$F")
sendstr = sendstr & sOut2
sendstr = sendstr & chr(10)&chr(13)
oObj.opencom("9600,8,2")
a = oObj.rts(1)
oObj.sendstring(sendstr)
oObj.closecom()
' Falls Fehler an Senden zurückgemeldet werden soll kannst Du das hier machen:
Senden2Com = "meine Fehlermeldung"
End Function
Etwas umständlich, aber so besser nachzuvollziehen.
Hilft Dir das weiter?
Gruß eBayer