Copy link to clipboard
Copied
Hi Expert
I want to convert TextFrame or Image to Button using script But in object model I not found any method to convet it in button.
Object-->Interactive->convertToButton
http://forums.adobe.com/message/3788171
I also not found convertToObject() in object method.
b = app.selection[0];
b.convertToObject ();
How convert TextFrame to Button using script ?
Thanks.
Hi Bill
Have you tried this?
...#target indesign
var myDocument = app.documents.add();
var myDocument = app.documents.item(0);
var myPage = myDocument.pages.item(0);
var myTextFrame = myPage.textFrames.add();
myTextFrame.geometricBounds = [72, 72, 288, 288];
myTextFrame.contents = "This is some example text."
//var myTextFrame = app.activeDocument.textFrames[0];
var myButton = convertToButton(myTextFrame);
function convertToButton(obj)
{
app.selection = [obj];
var maCreateButton = app.menuAction
Copy link to clipboard
Copied
Hi Bill joy,
You can refer the following link which is on forum:
http://forums.adobe.com/message/2773521#2773521
Suresh
Copy link to clipboard
Copied
Thanks SureshKumar for reply
I follow the link
http://forums.adobe.com/message/2773521#2773521
and try :
#target indesign
var myDocument = app.documents.add();
var myDocument = app.documents.item(0);
var myPage = myDocument.pages.item(0);
var myTextFrame = myPage.textFrames.add();
myTextFrame.geometricBounds = [72, 72, 288, 288];
myTextFrame.contents = "This is some example text."
//var myTextFrame = app.activeDocument.textFrames[0];
var myButton = convertToButton(myTextFrame);
But it give error convertToButton is not a function.
Thanks
Copy link to clipboard
Copied
Hi Bill joy,
You have to add the following defintion for the fuction convertToButton(myTextFrame)
function convertToButton(obj)
{
app.selection = [obj];
var maCreateButton = app.menuActions.item('$ID/$$$/Dialog/CmdName/CreateButton'),
ret;
if( !maCreateButton.isValid ) return false;
maCreateButton.invoke();
ret = app.selection[0];
return ret;
}
Suresh
Copy link to clipboard
Copied
Hi Bill
Try this
var myTextFrame = myDocument.buttons.add(myDocument.layers);
myTextFrame.geometricBounds = [72, 72, 288, 288];
Hurix
Copy link to clipboard
Copied
Hi hurix
thanks for reply
I want to convert TextFrame to Button.
Not to create a button.
this
var myTextFrame = myDocument.buttons.add(myDocument.layers);
myTextFrame.geometricBounds = [72, 72, 288, 288];
create button not convert in button.
I want to do Object-->Interactive->convertToButton using script.
Thanks
Copy link to clipboard
Copied
Hi Bill
Have you tried this?
#target indesign
var myDocument = app.documents.add();
var myDocument = app.documents.item(0);
var myPage = myDocument.pages.item(0);
var myTextFrame = myPage.textFrames.add();
myTextFrame.geometricBounds = [72, 72, 288, 288];
myTextFrame.contents = "This is some example text."
//var myTextFrame = app.activeDocument.textFrames[0];
var myButton = convertToButton(myTextFrame);
function convertToButton(obj)
{
app.selection = [obj];
var maCreateButton = app.menuActions.item('$ID/$$$/Dialog/CmdName/CreateButton'),
ret;
if( !maCreateButton.isValid ) return false;
maCreateButton.invoke();
ret = app.selection[0];
return ret;
}
Suresh
Copy link to clipboard
Copied
Try the convertToButton button, that works fine.
Peter
Copy link to clipboard
Copied
Thanks Peter for reply