| Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next 1 | 1. Reginald and Excel #12406 | 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) | 2. #12407 | 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. | 3. 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 )
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 | 4. Well, after a load of trial and error .. #12419 | 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 | 5. 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:-) | 6. and if iterateexe doesn't work .... #12422 | then you know it's worth giving it a try with command. (Having said that, the 'M' option of iterateexe is nice) | 7. An append to the above #12489 | 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 | Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next 1 |
|
|