SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Passing file name to MS Word

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
Passing file name to MS Word
Author Message
Luis



Joined: 07 Oct 2002
Posts: 2

Post Passing file name to MS Word Reply with quote

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:

Mon Oct 07, 2002 5:41 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7966

Post Re: Passing file name to MS Word Reply with quote

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:

Mon Oct 07, 2002 8:46 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.