Thanks, everything helps, and I'll definitely consider the ctrl-shift-home! EDIT: Macro doesn't work with this anymore as clipboard really comes back as empty!
I am now banging my head against another issue: I need to add line feeds inside the string variables in mmm, which isn't obvious!
Interesting.. You mean selecting a cell with text, hitting F2 to go into edit mode (cursor by default is positioned at the END of the text), then hitting Ctrl-Shift-Home *doesn't* select all the text and position the cursor at the start of the text for you?
That's cool to know - like i say the differences I've seen are very minor, like where if you F2 then Ctrl-Shift-arrow left/right in some versions selects all, in some it will only select up to the next slash, but I thought that Ctrl-Shift-Home/End were pretty universal across all the versions out there.
Thanks for that info! All my macros basically involve taking data out of excel and using it in another system, or vice-versa and I often test stuff at home on one version and then run at work on another, which is how I noticed the example I gave earlier so other minor differences like this can be valuable to me.
Your issue with adding CRLF to a string variable got me going down a rabbit hole last night for no good reason
I don't actually know of a good solution, and this would be a horrible dirty workaround but IIRC in excel (if you're actually using excel in the macro you're talking about) you can add a CRLF by using Char(10) in a formula.
It also doesn't address your issue of having the string variable directly contain the line break, it's only a quick & dirty way of inserting one into a text string you can copy to windows clipboard.
So if I type literally into a cell; ="test"&CHAR(10)&"test"
then it comes out as...
test
test
..and if you then convert the formula to it's value using F9 or somesuch, this string can be pasted into notepad and it retains the line break which got me very excited!
At least this could be handy if you're taking the source strings from excel, or inputting them into excel.
But when I tried to test this theory in a test macro I ran into issues, because when I used RUN ACTION | KEYPRESS the () characters don't seem to output, which breaks the use of CHAR(10).
1 | RUN ACTION | DEFINE STRING VARIABLE | %STRING1%::"Test1"
2 | RUN ACTION | DEFINE STRING VARIABLE | %STRING2%::"Test2"
3 | RUN ACTION | DEFINE STRING VARIABLE | %STRING3%::CHAR(10)
4 | RUN ACTION | WAIT MILLISECONDS | 500
5 | RUN ACTION | KEYPRESS | =
6 | RUN ACTION | KEYPRESS | %STRING1%
7 | RUN ACTION | KEYPRESS | &
8 | RUN ACTION | KEYPRESS | %STRING3%
9 | RUN ACTION | KEYPRESS | &
10 | RUN ACTION | KEYPRESS | %STRING2%
(I know it's long code and not necessary to have so many lines, but I used them just for an easy to read visual example)
I would expect the output of this test to be...
="Line1"&CHAR(10)&"Line2"
Which excel would then treat as a function due to the leading = and wrapping the text strings in quotation marks, but instead it comes out as...
="Line1"&CHAR10&"Line2"
[note the lack of () brackets in the output above]
Anyway you've possibly looked at this already, but if MMM can be forced into keypressing the brackets, it was at least a line of inquiry that might be worth looking into?
Sorry I couldn't have been more help, I'll be interested to see how you solve it!
*EDIT TO ADD* I notice an older thread
here that discusses brackets in Keypress actions - I might have a play later today to see if this resolves the issues i had in testing..
But of course this long-winded idea still is only of use if you're taking data from or inputting to excel and is probably very cumbersome to write if you need very many strings to contain line breaks.
*EDIT-EDIT* Recording keypress shift+|9 for "(" and shift+|0 for ")" does insert brackets as-per the thread linked, and the test output into excel works, and the result then can be copy/pasted into notepad with line break present.
I wonder if the formula output of two strings separated by CHAR(10) can be copied to windows clipboard,
then %clipboard% passed to a MMM string variable, and the next time you use that variable it still has the line break?
Will have a play later!