04-05-2019 06:53 AM
I want to convert the values of some channels with frequency 5 HZ and transfer them to Excel. I wrote these codes but this error happens: Invalid channel in command ChnResampleFreqBased, Parameter [1]. Can someone tell me, where is the cause of error in code.
Thank you very much.
Dim oExcel,oWBook,oSheet,K,L,oGroup,lCol,oChn,DisplayType,Sfile
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
Call oExcel.Workbooks.Open("N:\01_IMO-Light\Test\DIAdem-Test.xlsx")
Set oWBook = oExcel.Activeworkbook
' we want just one sheet !
If ( 1 < oWBook.Sheets.Count ) Then
For K = 1 To oWBook.Sheets.Count-1
Call oWBook.Sheets(1).Delete
Next
End If
Set oSheet = oWBook.Sheets(1)
oSheet.Name = "DIAdem_Export"
'Set oSheet = oWBook.Sheets.Add
lCol = 1
For K = 1 To Data.Root.ChannelGroups.Count
Set oGroup = Data.Root.ChannelGroups(K)
For L = 1 To oGroup.Channels.Count
Set oChn = oGroup.Channels(L)
if oChn.Name = "Eng_Spd" or oChn.Name = "Eng_Trq" or oChn.Name = "Eng_Trq_indicated" or oChn.Name = "InjCrv_qSetUnBal" or oChn.Name ="Veh_Spd" then
if oChn.Name = "Eng_Spd" then
Call ChnResampleFreqBased("[K]/time","[K]/Eng_Spd","[K]/Eng_Spd",5,"Automatic",0,0)
Else
end if
oSheet.Cells(1,lCol) = oChn.Name
oSheet.Cells(2,lCol) = oGroup.Name
oSheet.Cells(3,lCol) = oChn.Properties("unit_string").Value
'Call ChannelToExcelColumnBlk(oChn,oExcel,oSheet,lCol,4)
lCol = lCol + 1
else
end if
Next
Next
04-05-2019 08:08 AM
04-05-2019 09:24 AM
Thank you for replay ,best regards!