08-03-2020 03:35 PM
Hallo Diadem Experten,
in einer Exceldatei stehen Signalnamen. Per Skript soll geprüft werden, ob diese in der aktuell geladenen Messdatei enthalten sind, um weitere Prüfungen durchzuführen.
An sich ist die Fehlermeldung klar, aber wie kann ich meine Signalliste in ein Data Objekt überführen, um die Existenz von Signalen zu prüfen, bzw. wie würde eine mögliche Lösung aussehen?
'Diadem 2019 Sp1
'Lesen der Signalliste
Dim iReihe, iSpalte
Dim objAlleSignale : Set objAlleSignale = Data.GetChannels("*")
Dim objArbeitsmappe : Set objArbeitsmappe = CreateExcelWorkbook("c:\Temp\Signalliste.xlsx")
Dim objBlatt : Set objBlatt = objArbeitsmappe.Worksheets(1)
For iReihe = 1 to 5
Set objZelle = objBlatt.Cells(iReihe, 1)
Next
' Fehlermeldung: Das Argument "Element" der Methode "Exists" muss ein Element <Data> sein
For iReihe = 1 to 5
If objAlleSignale.Exists((objBlatt.Cells(iReihe, 1).Value)) Then
Msgbox("Success")
End If
Next
Gruß
R.Keller
Solved! Go to Solution.
08-04-2020 10:55 PM
Hi R. Keller,
I agree that the error message you're getting sounds like it's complaining about the argument, but I believe it's actually complaining about the parent object "objAlleSignale" not having that "Exists()" method. It's odd that the code completion suggests that it does, but that appears to be the problem. I suggest you use the Data.GetChannels() method instead, like this:
For iReihe = 1 to 5
ChannelName = objBlatt.Cells(iReihe, 1).Value
If Data.GetChannels(ChannelName).Count > 0 Then
Msgbox("Success")
End If
Next
Regards,
Brad Turpin
Principal Technical Support Engineer
National Instruments