Guidance
指路人
g.yi.org
Guidance Forums / Reginald Rexx / Reginald and Excel

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Reginald and Excel
#12406
Posted by: Michael S 2008-10-10 21:12:39
I have a program that creates a simple txt file - has anyone any experience of importing the data into Excel without explicitly opening/starting Excel and running a macro to import the data. (I want to "put" the data into Excel and have no idea where to start - if it's doable)
Message2.
#12407
Posted by: Jeff Glatt 2008-10-11 01:49:07
You can cause Excel to load itself and import a file using COM. I don't remember if there's an example in my zip of COM scripts.
Message3. This is a bit similar to the append on comparing files
#12416
Posted by: Michael S 2008-10-15 01:53:41 Last edited by: Michael S 2008-10-15 02:59:08 (Total edited 3 times)
I have the following code

file1_compare = 'h:\a_shb_rexxcode\bgst_before.txt'
file2_compare = 'h:\a_shb_rexxcode\bgst_after.txt'
temp = 'h:\a_shb_rexxcode'
diff_file = 'excel_diff.txt'
excel_dir = "c:\program files\microsoft office\office11"
excel_args = '/e/'file1_compare'§'file2_compare'§'temp'\'diff_file
excel_args "/e/fred"
excel_workbook = '"c:\program files\a_shb_rexxcode\test_excel_command.xls" 'excel_args
ITERATEEXE('"'excel_dir'\excel.exe"', excel_workbook /*, , ,'M' */ )
Is this method not allowed (since it doesn't seem to do anything - the "same" command works fine in a DOS window). In the xls file, I have an open workbook event, which checks for the occurrence of any parms. If there are any, it kicks off a module that will load various files.

Sorry, I should have said, that the iterateexe call works fine as long as I don't try to pass a parameter

Another update as I attempt to get it working. I changed the second parm so that the xls workbook was directly under the c-drive Ie, no imbedded blanks in the path). THEN it worked, so the question is - are there special hoops I have to jump through when I have an imbedded blank in the path to the workbook ? (I thought I had that covered with the use of double quotes)

Then I tried the following

ITERATEEXE(excel_cmd, excel_workbook, '/e/fred') 

It loaded the workbook correctly (ie, the one WITHOUT imbedded blanks), but THEN it complained that it couldn't find
\e\fred.xls   (Yes - the forward slashes became back ones instead)
If I enter the following in a DOS window
"c:\program files\microsoft office\office11\excel.exe" "c:\program files\a_shb_rexxcode\test_excel_command.xls" /e/fred
then everything works fine
Message4. Well, after a load of trial and error ..
#12419
Posted by: Michael S 2008-10-15 04:51:02
the following finally worked

LIBRARY rxcmd
err = command('"c:\program files\microsoft office\office11\excel.exe" "c:\program files\a_shb_rexxcode\test_excel_command.xls" /e/fred')
Would it be interesting to know why this works but not iterateexe
Message5. Well, after a load of trial and error
#12421
Posted by: cliff 2008-10-16 06:48:17
Michael,

thanks for ferreting that out.
I wanted my app to open files in NotePad++ but couldn't get it to work
with the iterateex, now I can.
cliff:-)
Message6. and if iterateexe doesn't work ....
#12422
Posted by: Michael S 2008-10-16 13:54:03
then you know it's worth giving it a try with command. (Having said that, the 'M' option of iterateexe is nice)
Message7. An append to the above
#12489
Posted by: Michael S 2008-10-30 17:00:02
I didn't want to give up the possibility of being able to call Excel without tieing up the calling script, so I persevered on the above. I've learnt a couple of things with this. First of all, if you're going to try something "unexpected/complicated" with iteratexe, try testing your combination in a DOS window and also in a simple test script. I've attached an example of the DOS call below. Here is the test script that I finally go to work

excel_cmd = "c:\program files\microsoft office\office11\excel.exe"
excel_workbook = "H:\Excel\Compare_DB2_Unloads.xls"
excel_args = "/e/H:\A_SHB_rexxcode\FUBETEST_INNAN.txt@H:\A_SHB_rexxcode\FUBETEST_EFTEr1.txt@H:\Excel\excel_diff.txt@"
ITERATEEXE(excel_cmd, excel_workbook, , , excel_args,'M')

I thought this was EXACTLY the same as I had in my code (that was failing), but it turned out that in the failing code I had the following

excel_workbook = '"'excel_workbook'"'

on the assumption that if it contained blanks, I needed to surround it with quotes, and it was this that was causing the error. In addition, I also hadn't understood the idea that my arguments to Excel's workbook needed to be passed as the 5th argument

excel_call_in_dos.png
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2024-3-29  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0