Sign in to follow this  
Followers 0
callelundin

CiCode quest! Open Excel file from a tag.

9 posts in this topic

Hey there! First of all, thanx for the help in my last three. I got my logg function perfect now, but now i stand before a new problem. I whant a button on my page that will activate a digital tag, lets call it "opentag", when "opentag" is high (1) i whant to open a file in Excel. The excel file is named rapport.dbf. Im played around with FileOpen function and DDE execute but dont know if im doing it right! Maybe somebody could give me a point "how to" do it and what i need to do it. I guess there is some simple way for this but i cant seem to figure it out. Flow: Push button on graphic page, button activate TAG, Tag activate CiCode function, CiCode open *.dbf in Excel. Thanks! :D

Share this post


Link to post
Share on other sites
You need to use the Exec function, for example like this, you can just run this direct from a button, not quite sure why you would want or need a tag to trigger it though, sure you can work out how to do that if you really need to: Exec("C:\Program Files\Microsoft Office\OFFICE11\Excel.exe C:\My_Files\My_File.dbf",3);

Share this post


Link to post
Share on other sites
Hey, thanks! I cant get the function to work! :/ i dont know why.. ? But thanks for the tip! :)

Share this post


Link to post
Share on other sites
Hey Sparky! I got this to work now. Im trying to use this in a multiple way i need to have "My_File.dbf" to be an variabel... so that the operater can choose what file to open. Is there in anyway posible to change the "My_File" part to an STRING Var? Something like this? Exec("C:\Program Files\Microsoft Office\OFFICE11\Excel.exe C:\My_Files\TEMP_STRING_VAR.dbf",3);

Share this post


Link to post
Share on other sites
Exec("C:\Program Files\Microsoft Office\OFFICE11\Excel.exe C:\My_Files\TEMP_STRING_VAR.dbf",3); I can't give you the code but I can give you the idea..... You need to look at string manipulation ie - define a string variable say strFileLoc and strFileToOpen Then define strFileLoc = "C:\Program Files\Microsoft Office\OFFICE11\Excel.exe C:\My_Files\" strFileToOpen = Operator input Then strFileLoc = strFileLoc + strFileToOpen if + does not work then mabey functions like concatenate might exist then Exec (strFileLoc,3);

Share this post


Link to post
Share on other sites
In its simplest terms it would be: Function File_Name() Exec("C:\Program Files\Microsoft Office\OFFICE11\Excel.exe C:\My_Files\"+FileName+".dbf",3); End

Share this post


Link to post
Share on other sites
Thanks everybody! I did it like Sleepy Wombat pointed me to.. They just edit a string in the graphic area example 08-08-10 then they push a button "Show me logg" that will set TAG_exec_logg_EON_kWh=1, works great! :D FUNCTION open() !! This function opens the loggfiles of the factrory !! STRING Temp1, Temp2, Temp3, Temp4; !! Putting TAGs toghter !! Temp1="C:\Program\Offic12\Excel.exe C:\db\EON\kWh\"; Temp2=TAG_sok_EON_kWh; Temp3=".dbf"; Temp4=Temp1+Temp2+Temp3; !! Executeing the searchway !! IF TAG_exec_logg_EON_kWh=1 THEN Sleep(2) Exec(Temp4,3) Sleep(2) TAG_exec_logg_EON_kWh=0 END END

Share this post


Link to post
Share on other sites
Well done Callelundin... Just some thoughts on the programming practices... I know it is all too easy to simply throw in tags like temp every where ... but use them sparingly. Try to assign symbolic names that make sense and also look into how programmers define a variable type... for example strings will usually have "str" preceding the variable name. intergers might have "int" or i and floats may have "flt" By doing this, at a glance a person can recognize variable types etc straight away. Regards Matt.

Share this post


Link to post
Share on other sites
Thanks! :) Yeah i actully do that in Global tags offen, but as you say, i maybe should use it allways instead! I'll try to think about it further on! :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0