When editing the toolbar button or hotkey, set the Function drop-down to Script Function.
In Opus 12 or above, set the Language drop-down to VBScript.
(If using Opus 11 instead, add an extra line with @script VBScript to what's below.)
Paste this code into the large, main field in the button editor:
Option Explicit
Function OnClick(ByRef ClickData)
Dim fso, tfile, txt
Set fso = CreateObject("Scripting.FileSystemObject")
Set tfile = fso.OpenTextFile("p:\directory\filename.txt")
txt = tfile.ReadAll
DOpus.SetClip txt
End Function
That will read p:\directory\filename.txt into memory and put the text into the clipboard.
You could turn the script into a Script Add-In which adds a command you can use like that in other buttons. (The command would have to have a different name, since there's already a Clipboard command, but apart from that it could work exactly as you want.)
[quote="LITWINCZUK"]Is a little strange to copy/paste over entire buttons where i want to use it.
Browse for file and add "CLIPBOARD CONTENT=".........." - or something like this will be simpliest way....[/quote]
To get you started, here is the updated code that will copy content of any selected file to clipboard
Option Explicit
Function OnClick(ByRef ClickData)
Dim fso, tfile, txt
If ClickData.func.sourcetab.selected_files.Count > 0 Then
Set fso = CreateObject("Scripting.FileSystemObject")
Set tfile = fso.OpenTextFile(ClickData.func.sourcetab.selected_files(0))
txt = tfile.ReadAll
DOpus.SetClip txt
End If
End Function
[Script code updated, as per the next post below. --Leo]