#39476 - 2003-04-23 07:56 PM
Reading from an Excel File
|
Tomalok
Fresh Scripter
Registered: 2003-04-23
Posts: 6
Loc: Berne, IN
|
I am trying to write a script to read from cells C3 and C6 in an Excel file. If the event reads "overdue" then have a message box come up and tell the user they need to do a new machine set up. I am having trouble finding the right syntax to set this up. This is my first Kixtart script and so far, no good... Can anyone help?
|
|
Top
|
|
|
|
#39478 - 2003-04-23 08:10 PM
Re: Reading from an Excel File
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
|
|
Top
|
|
|
|
#39479 - 2003-04-25 05:50 PM
Re: Reading from an Excel File
|
Tomalok
Fresh Scripter
Registered: 2003-04-23
Posts: 6
Loc: Berne, IN
|
I have the script reading the file, but it will not close Excel automatically. Is there a special function to close the file without asking for it to save if there is not changes to the file??
Thanks
|
|
Top
|
|
|
|
#39480 - 2003-04-25 05:58 PM
Re: Reading from an Excel File
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
might try:
code:
$xls.UserControl = 1 $= $xls.quit
|
|
Top
|
|
|
|
#39482 - 2003-04-25 06:27 PM
Re: Reading from an Excel File
|
Tomalok
Fresh Scripter
Registered: 2003-04-23
Posts: 6
Loc: Berne, IN
|
No luck so far. Here is my code. This is my first venture using KixTart in many years code:
break on
$objXL = CreateObject("EXCEL.application")
if @error = 0
$rc = $objXL.Workbooks. $objWorkbook = $objXL.Workbooks.Open("c:\WeldFlag.xls") $objWorksheet = $objWorkbooks.ActiveSheet
$objCell = $objWorksheet.Range("c3")
If $objCell.Value = "overdue" $objXL.Visible = 1 $Selection = MessageBox ("Please do a new Setup on Welder 601", "OVERDUE SETUP ON 601", 36) If $Selection = 6 ? "Enter New Setup Date on Worksheet and Anstat" sleep 4 Endif Endif break off $Selection = MessageBox ("NO Setup NEEDED on Welder 601", "Good SetUp ON 601", 64)
$objXL.Quit $objXL = 0
:end
|
|
Top
|
|
|
|
#39484 - 2003-04-25 06:41 PM
Re: Reading from an Excel File
|
Tomalok
Fresh Scripter
Registered: 2003-04-23
Posts: 6
Loc: Berne, IN
|
Aded extra endif and $objWorkbook.close(), but it still comes up with a box asking if I want to save the file. I am wanting it to run in the background with no user intervention if no "Setup" is needed. And since it still asks to save the file, it does not yet work correctly.
Jeff
|
|
Top
|
|
|
|
#39487 - 2003-04-25 06:59 PM
Re: Reading from an Excel File
|
kholm
Korg Regular
   
Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
|
To avoid the save dialog, use:
code:
$oXl.DisplayAlerts = 0 $RC = $oXl.Quit
-Erik
You might get som more idaes from my post: Collection of UDF's for Excel
Sorry i have not made this ready for the UDF-forum. Anyone is welcome [ 25. April 2003, 19:16: Message edited by: kholm ]
|
|
Top
|
|
|
|
#39488 - 2003-04-25 07:53 PM
Re: Reading from an Excel File
|
Tomalok
Fresh Scripter
Registered: 2003-04-23
Posts: 6
Loc: Berne, IN
|
Erik,
IT WORKED! I changed your syntax to match mine (oXl to objXL)
To: LLigetf, What is SRFW????
Thanks
|
|
Top
|
|
|
|
#39489 - 2003-04-25 07:55 PM
Re: Reading from an Excel File
|
Tomalok
Fresh Scripter
Registered: 2003-04-23
Posts: 6
Loc: Berne, IN
|
LLigetfa
Sorry about my poor typing, I was overcome with joy in that it finally worked. What is STFW?
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1058 anonymous users online.
|
|
|