In general you need to concatenate the value of the variable to the command line like the following (if the program or file contains paces, that part of the command line must be enclosed in double quotes) Dim Full_Command, string Concat( "\"c:\\program files\\microsoft office\\office\\winword.exe\" ", full_file_name, Full_Command ) Run( Full_Command, and so on ... In your particula case you don't need to build the full command line. Just run the .DOC file 24x7 is smart enough to figure out you are running a document file and it will automatically find and launch the driver application such as MS Word. So you code could be simplified to the following Run( full_file_name, "c:\\testreformat", ret ) Also check out RunWithInput command that can be used instead of a bunch of Run, Wait and SendKeys, for example RunWithInput( full_file_name, "c:\\testreformat", 6, "{ALT}FC{ESC}{CTRL}R{WAIT 5}{ESC}{ALT}FS{WAIT 5){ESC}{ALT}FX", 0, ret ) This command will also cause 24x7 to wait for the MS Word to exit before running the next file. : I am writing a script to list all the MS Word files : in one directory, then open each file in Word. : My problem is how to pass the file name to MS Word : using a variable. : here is the script so far: //This script finds all MSWord files in a : directory, : //then opens each file in MSWord and send key strokes to execute : //MSWord macros to remove headers, footers and change the margins. : Dim( found_files, string ) : Dim( is_empty, boolean, FALSE ) : Dim( file_name, string ) : Dim( full_file_name, string ) : Dim ret, number : Dim( prefix, string ) : Dir( "C:\TestReformat\*.doc", found_files ) : IsEqual( found_files, "", is_empty ) : // parse file names : //LoopUntil( is_empty, END_LOOP ) : GetToken( ",", found_files, file_name ) : // Open MSWord : print file_name : set prefix, "C:\\TestReformat\\" : Concat( prefix, file_name, full_file_name ) : Run( "c:\\program files\\microsoft office\\office\\winword.exe : full_file_name", "c:\\testreformat", ret ) : Wait(6) : //SendKeys( {ALT}FC ) : //SendKeys( {ESC} ) : //SendKeys( {CTRL}R ) : //Wait( 5 ) : //SendKeys( {ESC} ) : //SendKeys( {ALT}FS ) : //Wait( 5 ) : //SendKeys( {ESC} ) : //SendKeys( {ALT}FX ) : //Wait(6) : // Send key strokes to MSWord to execute macros : // check if there is more files in the list : IsEqual( found_files, "", is_empty ) : END_LOOP:
|