VBScript in WinCC v11

userxyz

Member
Join Date
May 2002
Location
any
Posts
2,768
Hi,

I get Error E429, ActiveX Object Cannot be created when running the following script on a TP700 panel:

Code:
Sub Logging()
Dim fs, f, DataSet, Dataformat, file_path, file_name, file_name_path, Str1, Str2, Str3, Str4, Str5, y, m, d
	
y = Year(Now)
m = Month(Now)
d = Day(Now)

If Call_Script = True Then
	
Delay(5) '5 seconds delay

On Error Resume Next

Set fs = CreateObject("filectl.filesystem")
Set f = CreateObject("filectl.file")	

If Eventdata_Gestart Then 
	Str1 = "Machine Gestart"
Else
	Str1 = "Machine Gestopt"
End If

If Eventdata_Alarmbit Then 
	Str2 = "Alarm Actief"
Else
	Str2 = ""
End If

If Eventdata_Deuren Then 
	Str3 = "Deur Open"
Else
	Str3 = ""
End If

If Eventdata_Reset Then 
	Str4 = "Machine Reset Bezig"
Else
	Str4 = ""
End If

If Eventdata_Keuze_Recept Then 
	Str5 = "Nieuw Recept gekozen"
	Runnr = Runnr + 1
Else
	Str5 = ""
End If

file_path = "C:\Server\Logging\" 
file_name = CStr(y) & "_" & CStr(m) & "_" & CStr(d) & "_" & "_Recnr" & ".csv"
file_name_path = file_path & file_name

Dataformat = ("Datum" & ";" & "Tijd" & ";" & "Machine Gestart" & ";" & "Alarm" & ";" & "Deuren" & ";" & "Reset" & ";" & "Receptwijziging" & ";" & "Naam" & ";" & "Teller" & ";" & "Profieltijd (min)" & ";" & "Stuktijd (s)")   
DataSet = (Date & ";" & Time & ";" & Str1 & ";" & Str2 & ";" & Str3 & ";" & Str4 & ";" & ACTIEF_PRODNAME & Productieteller & ";" & cyclustijdprofiel & ";" & Cyclustijdstuk)
If Err.Number <> 0 Then
 ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
 Err.Clear
 Exit Sub
End If

	
If fs.dir(file_name_path)="" Then
	f.open file_name_path, 2  'Construct 
	f.LinePrint Dataformat
	f.Lineprint DataSet
	f.close
Else
	f.open file_name_path, 8 'Append
	f.Lineprint DataSet
	f.close
End If


If Err.Number <> 0 Then
 ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
 Err.Clear
 Exit Sub
End If

Set f = Nothing
Set fs = Nothing

Call_Script = 0

ShowSystemAlarm "Historian storage was successful"

End If
End Sub

Any help would be great,
Thanks,
Combo
 

Similar Topics

Hello, I have a quick question. I have been using scripts to change the color of buttons. The reason, I am usually using multiple hmiruntime.tags...
Replies
1
Views
113
Hi, I tried this: HMIRuntime.Screens("Mainscreen.bottomwindow:bottomwindow").ScreenItems("btn_body").back.color = RGB(255,255,255)...
Replies
1
Views
3,632
Hey guys. I am tyring connect from my HMI (TP1200) to a network location and open a file from a folder. The twist is I don't know what the file...
Replies
1
Views
4,738
Hi! I have no experience at all with VB script but I think I might need something here. The issue is that we mainly have the WinCC Flexible to...
Replies
2
Views
7,362
What do I need: When They want to do an Import, this is called: DeleteDataRecordMemory hmiFlashMemory, hmiOff, hmiOn...
Replies
2
Views
7,083
Back
Top Bottom