Jump to content
Macro Express Forums

Adding different lines from a file to a loop


prufrock101

Recommended Posts

I have a file and a macro loop. I want part of the macro loop to involve typing or pasting a different line from the file each iteration... the first iteration will use the first line, the second iteration the second line... etc. I can't seem to figure out how to do this. Help?

 

Thanks

Link to comment
Share on other sites

I have a file and a macro loop. I want part of the macro loop to involve typing or pasting a different line from the file each iteration... the first iteration will use the first line, the second iteration the second line... etc. I can't seem to figure out how to do this. Help?

 

If it's a text file, and not too huge, try something like this:

 

Launch notepad passing it the file name (or just open it manually if this is a one-time chore)

Type CTRL_Home to position at beginning of file

Repeat begin

Type Shift_End to highlight current line of file

Type CTRL_C to copy line to clipboard

Check whether it is time to exit from repeat loop

Type Home and arrow down to position to next line of file

Activate window that you want to paste into

Type CTRL_V to paste from clipboard

Activate notepad window

Repeat

 

You will have to use some kind of logic to exit from the loop at end of file. Maybe insert a dummy line of funny characters that you can check for after you copy into the clipboard.

 

Alternatively, I think the help screens or the online knowledge base describe a better technique of bringing the whole file into a variable, then indexing through the variable to handle one line at a time. I've never done it and I don't know the details.

Link to comment
Share on other sites

It sounds like you would want to use the Text File Begin Process. This file reads the first line of the file and saves to a variable. Do what you need with the variable and close the loop with a Text File End Process command. The macro then loops back and reads line 2 of the file, and so on until the end of the file.

 

The help topic explains this in more detail.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...