Answered
Javascript to copy clipboard contents to selected form field description?
Is there a way to copy clipboard content to the description of the form field i have selected?
Is there a way to copy clipboard content to the description of the form field i have selected?
Hello @LynxKx,
Give the below code a try...
function Main() {
function GetClipboard(){
var clipboard;
if(File.fs == "Macintosh"){
var script = 'tell application "Finder"\nset clip to the clipboard\nend tell\nreturn clip';
clipboard = app.doScript (script,ScriptLanguage.APPLESCRIPT_LANGUAGE);
} else {
var script = 'Set objHTML = CreateObject("htmlfile")\r'+
'returnValue = objHTML.ParentWindow.ClipboardData.GetData("text")';
clipboard = app.doScript(script,ScriptLanguage.VISUAL_BASIC);
}
return clipboard;
}
myDescriptionText = GetClipboard();
try {
mySelObject.properties = {
appliedFont: "Arial",
fontSize: 0,
fontStyle: "Regular",
description: myDescriptionText,
multiline: true,
scrollable: false
}} catch(e) {}
}
if (app.selection.length == 0) {
alert("Error!\nNothing is selected.");
}
else if (app.selection.length > 1) {
alert("Error!\nThere's more than one object selected.");
}
else if (app.selection.length == 1 && app.selection[0].hasOwnProperty("baseline")) {
alert("Error!\nThere's some text selected.");
}
else if (app.selection[0].constructor.name != "TextBox") {
alert("Error!\nNo form field Text Box is selected.")
}
mySelObject = app.selection[0];
Main();
Regards,
Mike
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.