I'm currently trying to write an AppleScript for my Touchbar, which does copy a predefined variable into the clipboard and then pastes it into a word document.
Well, it does work, but for some reason in addition of just pasting the variable text, it also adds a Enter/NewLine to it. Now I already did some testing and just assigned plain text directly to the clipboard and the NewLine was still there, so it isn't the variable. I also tested the Cmd+V output and also when I just paste the text manually afterwards it still pastes it with an enter, so it seems like there is something wrong with the assignment. But since I'm new to AppleScript and the language is really weird, I don't really get what I'm doing wrong here. Here is the important code part:
activate application "Microsoft Word" --I'm doing this, but you prolly don't need to.
set Donnerstag12 to "Anwendungsentwicklung"
set the clipboard to Donnerstag12
tell application "System Events" to keystroke "v" using {command down}
Now I just noticed that when I let AppleScript paste into Pages, TextEdit or straight into the code, it doesn't include a NewLine. Any Ideas?
You can use the type text
command of Microsoft Word.
set Donnerstag12 to "Anwendungsentwicklung"
tell application "Microsoft Word" to type text selection text Donnerstag12