Jump to content
Macro Express Forums

Fixed Variables


Recommended Posts

Hello

 

I'm Trying to create a macro to replace certain predefined text with entries in an excel file

 

for example:

 

I have 10 predefined symbols located in various places in a text file:

 

1. #^3

2. %f2

3. @4

4. %8

...etc

 

I would like to add those as fixed variables in the macro but i dont know how?

 

 

the macro will simply locate the symbol in a text file, and replace it with an entry that I copied from excel

 

macro will be :

 

- go to excel and copy the first entry

- go to text file

- locate predefined symbol "#^3" in text file

- paste the excel entry in the place of the predefined text

- go back to excel and move to second row

- repeat process with second predefined symbol

 

 

never used variables before and i read the tutorials but wasnt able to figure out how to work with them, i would appreciate any advice

 

thanks

Link to comment
Share on other sites

Your description isn't clear to me……………………………..

I understand that you have a text file with some values and you want to copy something from Excel and have MEP replace a bit of text in your text file with what you copied. But how will the macro know which to replace? But for the moment I will take a stab at it.

 

I would first set a variable to the contents of your text file and when you copy from Excel to your clipboard read that in as a variable as well. Then I would simply replace a substring and write it back to file.

Variable Set String set %File Contents% to the contents of c:\somefile.txt
Variable Set String %Clipboard% from the clipboard contents
Variable Modify String: Replace "#^3" in %File Contents% with "%Clipboard%"
Variable Modify String: Save %File Contents% to "c:\somefile.txt"

However the more I think on it I believe you might be going about this all wrong depending on what exactly you are trying to do. If you tell me in general what the task at hand is I might be able to point you in a better direction. One you haven’t thought of yet.

Link to comment
Share on other sites

Variable Set String set %File Contents% to the contents of c:\somefile.txt
Variable Set String %Clipboard% from the clipboard contents
Variable Modify String: Replace "#^3" in %File Contents% with "%Clipboard%"
Variable Modify String: Save %File Contents% to "c:\somefile.txt"

However the more I think on it I believe you might be going about this all wrong depending on what exactly you are trying to do. If you tell me in general what the task at hand is I might be able to point you in a better direction. One you haven’t thought of yet.

 

 

 

 

Variable Modify String: Replace "#^3" in %File Contents% with "%Clipboard%

 

that sounds exactly what i was looking for !

 

thanks!

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...