Hello,Please help to resolve on other task
Below I present some exotic codeCode must work so:Code window of VBE is active and this code is visible. Than I Select on 3-th row Dim and press F5 to run this codeWshShell.SendKeys "^c" emulate pressing Ctrl-C and copy selected Dim to Clipboard. If I press Ctrl-V text Dim is pasted.I expect that Dim will be printed in immediate window, but not. In immediate window appears the text selected before DimThan I select Set WshShell and run code pressing F5 or RunSub/User Form green triangle. If i press after that Ctrl-V - Set WshShell is pasted, but in Debug.Print sends to immediate window Dim /before selected/Than I select clipboardData - Ctrl-V paste clipboardData at cursor position, but in immediate window Set WshShell is printed and so on.For each cycle select TEXT2/RUN code TEXT2 appears when paste and before TEXT2 selected TEXT1 is printed in immediate window.And that would be right to paste the selected text TEXT2 after starting the code and to print the same text TEXT2 in the immediate window. Somehow things are moving one step backwards.А правилно би било селектираният текст след стартиране на кода да се залепя и същия текст да се отпечатва в immediate window. Някак си нещата се движат с една стъпка назад.
Sub PutSelectionToClipboard()'PUT selection of text in VBE Code window to Clipboard, then GET from Clipboard and assign to variable Dim clipboardData As DataObjectSet WshShell = CreateObject("WScript.Shell")WshShell.SendKeys "^c" WshShell.SendKeys "^g{F7}" 'to show Immediate VBE window, output for Debug.Print, than F7 activate Code windowSet clipboardData = New DataObject clipboardData.GetFromClipboardAAA = clipboardData.GetTextDebug.Print AAAEnd SubGreetings!