nhatto Posted October 26, 2009 Report Share Posted October 26, 2009 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 Quote Link to comment Share on other sites More sharing options...
nhatto Posted October 27, 2009 Author Report Share Posted October 27, 2009 any ideas? Quote Link to comment Share on other sites More sharing options...
Cory Posted October 27, 2009 Report Share Posted October 27, 2009 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. Quote Link to comment Share on other sites More sharing options...
nhatto Posted October 27, 2009 Author Report Share Posted October 27, 2009 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.