UAMike Posted March 20, 2017 Report Share Posted March 20, 2017 I am trying to build some logic into my macro that would select a string of text, copy it to the clipboard, and then run a specific macro based on what is stored in the clipboard (or a variable that was set to the clipboard content). So far, I have created a bunch of code like this: If Clipboard contains "brown" Variable Set String %macroname% to "brown" End If Macro Run: %macroname% This definitely works, but as I have a few thousand macros that could potentially be run, I am hesitant to continue doing it this way. Any ideas on an alternate approach to accomplish the same thing? Quote Link to comment Share on other sites More sharing options...
Cory Posted March 20, 2017 Report Share Posted March 20, 2017 You might want to create a CSV list of your keyword matches in one column and macro name in another and and repeat with it each time using ASCII File Process. Quote Link to comment Share on other sites More sharing options...
rberq Posted March 20, 2017 Report Share Posted March 20, 2017 See Help screens for the CASE / END CASE commands. It's a bit neater than IF / END IF but still a lot of lines in a single macro. Cory's method has the advantage that you can maintain the list independently of Macro Express. Quote Link to comment Share on other sites More sharing options...
acantor Posted March 21, 2017 Report Share Posted March 21, 2017 If there is consistency in the clipboard text, delete everything that is not a macro name. For example, let's say the clipboard text always is something like this... " 0123456789Colour = Brown " or this... " 0987654321Colour = Red " or this... " 3.14159265Colour = Turquoise " Variable Set String %Clip% from the Clipboard // A series of statements to parse out unwanted text... // e.g., delete leading/trailing white space, the first 10 characters, and the phrase "Colour = " Variable Modify String %Clip%: Trim Variable Modify String %Clip%: Delete a substring starting at 1 and 10 characters long Variable Modify String: Replace "Colour = " in %Clip% with "" Macro Run: %Clip% Quote Link to comment Share on other sites More sharing options...
UAMike Posted March 21, 2017 Author Report Share Posted March 21, 2017 20 hours ago, Cory said: You might want to create a CSV list of your keyword matches in one column and macro name in another and and repeat with it each time using ASCII File Process. This method worked perfectly! It took me a while to get the hang of using it and truth be told, I am not even that well versed in using arrays either, but I was amazed at how a few lines of code combined with a tab delimited document made this whole thing really easy. I was also worried about the ASCII file process taking too long to and slowing down the macro, but that wasn't an issue either. Thanks Cory and others for valuable suggestions. I can see myself using this method for other applications as well. Quote Link to comment Share on other sites More sharing options...
Cory Posted March 22, 2017 Report Share Posted March 22, 2017 You're welcome. 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.