Some Problem about Cimplicity CimBasic


Thread Starter

Zuo Zhihui

I use Cimplicity to make a SCADA System for a Hydropower Plant, now I have some problem about Cimplicity, so I ask these question to you and hope your answer as soon as early, Thanks! In my project, I make a Timely Event and CimBasic Script to a report table in every hour, but I find some problem about these. 1) I use "APPFIND$" to make sure if the "Microsoft Excel" is running now, I just copy the Basic Line from CimBasic Help file, but it can run clearly, I don't know why? 2) If the "APPFIND$" can make sure the Excel is running now, then I want the "GetObject" to make the link to Excel, but I get error; If I use "CreateObject" to make the link, it will open a new Excel file, that is not my hoped. How can I do this? Thanks again for answer!
Here, I paste my Script with some problems: Sub Main() Dim Excel As Object 'Check if the ProgFile Opened Call OpenExcel() Set Excel = GetObject (,"excel.application") 'Excel.Visible = True 'Query the DB & Log 'Excel.Application.Workbooks("PROG1.XLS").Activate Excel.Application.Run "PROG1.xls!LogFill" 'Excel.Application.Workbooks("PROG1.XLS").Activate End Sub Sub OpenExcel() Dim Excel As Object Dim FilePath As String Dim i As Integer 'Dim TabExist As Boolean 'On Error Resume Next FilePath = "F:\zsq\tab\" If AppFind$("Microsoft Excel") <> "" Then Set Excel = CreateObject ("excel.Application") Excel.Visible = True Excel.Workbooks.Open "F:\ZSQ\Tab\PROG1.xls" 'id = Shell("EXCEL.EXE F:\ZSQ\Tab\PROG1.xls", 2) Exit Sub End If Set Excel = CreateObject ("excel.application") Excel.Visible = True 'Check the Tab 'TabExist = False For i = 1 To Excel.Workbooks.Count If Excel.Workbooks(i).Name = "PROG1.xls" Then TabExist = True Exit Sub End If Next 'If TabExist = False Then Excel.Application.Workbooks.Open FilePath & "PROG1.xls" 'End If End Sub I have try many times to solve the problem I mentioned before, but I failed. Thanks a lot for help!

Paul Mentz - NEDDAM Software Technologie

Since you are running a "Timely" event, I assume you are triggering this using the event manager. You, need to open the CIMPLICITY service within NT and change the option to have the service log in as a user. Other things in your project may change as the result of this so testing of the entire system is required after the change and reboot. Since I haven't seen your entire project, this response may not be the answer to your situation, and I cannot take any responsibility for any problems that may occur as a result of you implementing this suggestion. If you are using this in a screen, here is some code I used for a custom C++ .exe that I called. The Process ID is stored as virtual text point. Dim id As Variant ID = PointGet("V_CT_AUTO_PROCESS_ID") If AppFind$(ID) = "" Then 'Make sure program is not already running id = Shell("c:\directory\myprogram.exe") 'Run PointSet "V_CT_AUTO_PROCESS_ID",ID PointSet "V_CT_START_AUTO",1 Else MSGbox "xxxxxxxx is already running, Initiating restart...." PointSet "V_CT_START_AUTO",1 End If Hope this helps Paul.
In your code, you are using the getobject function. I have a problem with it. I'm forced to open an excel file which contains broken link to other excel files.
And the context message provoked by these broken links freezes my execution.
Would you know how to prevent that from happening ?