Jump to content
Macro Express Forums

Find soemthing in a document and copy it out


Recommended Posts

Probably can be done with command Text File Begin Process, which loops for the entire file and passes one line at a time to a text variable.  Read about it in the Help section.  If you need to copy the whole line starting with @, it's easy.  If you need to copy less than the whole line, the hard part may be where to leave off -- that is, what delineates the end of the name to be copied?  

Show us a couple dozen representative lines; change the names to protect the innocent, if necessary. 

If your files are not text files, then ????

Link to comment
Share on other sites

How many words in each name? Or does the number of words vary?

If it's a fixed number of words, then selecting the names and copying them may be straightforward. Part of your script might look like this, assuming each name is two words long. (This is in pseudocode, but it's similar to Macro Express code

Type "<CONTROL>f"   // Find
Type "@<ENTER>"     // Search for @ and initiate the search
Type "<ESC>          // Cancel the search
Type "<CONTROL><SHIFT><RIGHT> //  Select the 1st word
Type "<CONTROL><SHIFT><RIGHT> //  Select the 2nd word
Type "<CONTROL>c" // Copy to the clipboard


In many text editors, pressing F3 repeats the previous search. In Microsoft Word, the hotkey is Shift + F5. Knowing these factoids might help simplify the project.

  • Like 1
Link to comment
Share on other sites

  • 3 months later...

I too have a similar situation and need some information extracted either from an order when it comes in through Gmail. Here is the situation.

An email from Barnes&Noble comes in notifying us a customer is ordering an item.. Every email has this information listed on separate lines (So it would copy data to the end of the line)


Ship To:
Mrs. Jane Doe
1234 Coppers Lane
Macro Express, ME 12345-6789

What I would like to know is:

 Can I extract this data from my emails into variables in Macro Express 3.11a, or would this be a feature in one of the upgraded versions.

If I can do it in this version, what are the basics on how to go about this. (Would I simply run the macro in the opened email in my browser to let it extract the variables there, or would I need to copy the entire email out to the clipboard or a text file?)

After I have this information set into variables I would have no problem manipulating the data into where I need it with the rest of the macro.


Thank You for your assistance...

Don Bulger..


  • This item must be shipped by: xxx
  • Your SKU: xxx
  • Title: xxx
  • Contributor/Manufacturer: xxx
  • Condition: xxx
  • Sold to: xxx xxx@aol.com
  • Order ID: 0123456789
  • Ordered on: 1/8/19
  • Price: 3.0
  • Commission: 0.45
  • Shipping Allowance: 3.75
Link to comment
Share on other sites

I re-read the previous response and had difficulty selecting the information to the end of the line that I am on. Unfortunately the information is not in a bulleted list or formatted with returns at the end of each line that I can tell. I tried using Ctrl Shift End which should have gone to the end of the line but what it selected was everything to the end of the email. I tried this both while looking at the email inside a browser, and I also copied and pasted the entire text of the email into notepad, and the command would select all the lines to the end of the email.

Is there a different command i should have used?


Link to comment
Share on other sites

Your Macro Express version 3 should be fine.  I do a fair amount of extracting like this, and I prefer ME 3 for its relative simplicity.  

You could probably have your macro:
1.    Type Ctrl-a to highlight the entire email.
2.    Copy highlighted text (entire email) to clipboard.
3.    Save the clipboard into a text variable and work with it there.  (Manually, while developing the macro, copy and paste the clipboard into Notepad so you can see what you are working with.)
4.    Find the position of “Ship to:” within the text, and delete all text up to and including “Ship to:”.
5.    Copy one line at a time into text variables and do with it what you want.
Of course the last step is where it starts to get sticky.  There is probably a carriage return and/or new line character at the end of each line.  If you can figure out what it is, you can use various string variable commands to copy up to the delimiter (into another variable), then delete it from the full text, go on to the next line, etc.  

For example, the macro snippet below extracts a dollar amount that I know is in the text, sandwiched between the literals “balance” and “transact”.   You would be extracting a line delimited by “Ship to:” or carriage-return/new-line.   

// Find target literal “balance” and delete everything to the left of it and including “balance”
Variable Set Integer %N46% from Position of Text in Variable %T45% [look for “balance”]
Variable Modify Integer: Dec (%N46%) [add 7 to include the word “balance” itself]
Variable Modify String: Delete Part of %T45% [delete everything up to and including “balance”]
// Find "transact" literal and delete it and everything to the right of it, then trim trailing blanks
Variable Set Integer %N46% from Position of Text in Variable %T45% [look for “transact”]
Variable Modify String: Delete Part of %T45% [delete “transact” and everything to the right]
Variable Modify String: Right Trim %T45%
// Back up 11 bytes from end of remaining data -- should be at or before the dollar amount we want
Variable Set Integer %N46% from Length of Variable %T45%
Variable Modify Integer: %N46% = %N46% - 11
// Copy target amount, 12 characters, into variable T50 for return to calling macro
Variable Modify String: Copy Part of %T45% to %T50%


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.

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.

  • Create New...