How to execute and close file after 10 Seconds

Aimin Ariff

Member
Join Date
Mar 2023
Location
Selangor
Posts
28
Guys, so I have doing cicode function, to execute excel file, the the values from the excel and extract it to the tags. The problem is, I dont know how to make it automatically close the excel file after read it. This is my cicode, please help me..

FUNCTION ReadData()
Exec("C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE C:\Users\USER\Desktop\Knowles\L1_Export_List.xlsx",6);
Temp1 = DDERead("Excel","Data Level1","R2C22");
Temp2 = DDERead("Excel","Data Level1","R4C22");
Temp3 = DDERead("Excel","Data Level1","R6C22");
Temp4 = DDERead("Excel","Data Level1","R7C22");
Temp5 = DDERead("Excel","Data Level1","R9C22");
Temp6 = DDERead("Excel","Data Level1","R11C22");
Temp7 = DDERead("Excel","Data Level1","R13C22");
Temp8 = DDERead("Excel","Data Level1","R16C22");
Temp9 = DDERead("Excel","Data Level1","R17C22");
Temp10 = DDERead("Excel","Data Level1","R19C22");
END


FUNCTION enginestart
WHILE (Start = 1) DO
ReadData()
Sleep(3);
END
END
 
You could do it in the excel file:

Private Sub Workbook_Open()
StartTimer
End Sub


Const idleTime = 10 'seconds
Dim Start
Sub StartTimer()
Start = Timer
Do While Timer < Start + idleTime
DoEvents
Loop
Application.DisplayAlerts = False
ActiveWorkbook.Close True
Application.DisplayAlerts = True
End Sub
 

Similar Topics

Hello experts. Anyone has any idea how to make BLKMOV execute only once? I have tried with R_TRIG and (P) but it wont write to my location.
Replies
3
Views
200
Hi, I am currently using ProgramExecute to open a Windows Explorer window in my application to a specific directory (WinCC 7.5). Is there a way...
Replies
1
Views
509
Hi guys, Im back again, this time I cannot minimized excel even though i put 6 on the exec mode.. this is my cicode.. Exec("C:\Program...
Replies
1
Views
1,095
Hello, The way I have it setup is that my PLC executes various calculations for example : Calculation 1, Calculation 2, Calculation 3...
Replies
3
Views
1,206
Hello, I am testing a Micro 820 and for whatever reason it won't execute the code. I am toggling inputs but the outputs still show as blue (off)...
Replies
1
Views
1,444
Back
Top Bottom