Highlighted

Am facing this error, try to find object fill color.

Community Beginner ,
Jun 25, 2020

Copy link to clipboard

Copied

"Error: Invalid value for set property 'fillColor'. Expected Swatch, String or NothingEnum enumerator, but received in indesign"

 

 

Am facing this error, try to find object fill color.
varmyColors = myDoc.colors;
var_counter = 0;
for(varl=0;l<myColors.length;l++){
if(myColors[l].name.search("DO NOT PRINT","i") >-1 || myColors[l].name.search("DO_NOT_PRINT","i") >-1 || myColors[l].name.search("DONOTPRINT","i") >-1 ){
_counter++;
if (_counter == 1) {
_DO_NOT_PRINT_Swatches.push(myColors[l].name);
_DO_NOT_PRINT_Swatches1.push(myColors[l].name);
}
else{
_DO_NOT_PRINT_Swatches.push("\t\t\t" +myColors[l].name);
_DO_NOT_PRINT_Swatches1.push(myColors[l].name);
}
}
}
for(vars=0;s<_DO_NOT_PRINT_Swatches1.length;s++){
app.findChangeObjectOptions.objectType = ObjectTypes.ALL_FRAMES_TYPE;
app.findObjectPreferences.fillColor = _DO_NOT_PRINT_Swatches1[s];
varresultObject = myDoc.findObject();
if(resultObject.length>0){
var_counter = 0;
for(varobj=0;obj<resultObject.length;obj++){
_counter++;
if(_counter == 1){
_Do_Not_Print_Object_Array.push("page "+resultObject[obj].parentPage.name+"-->"+_DO_NOT_PRINT_Swatches1[s]);
}
else{
_Do_Not_Print_Object_Array.push("\t\t\tpage "+resultObject[obj].parentPage.name+"-->"+_DO_NOT_PRINT_Swatches1[s]);
}
}
}
}
 
Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

Hi,

as far as I can see from your code, this line:

app.findObjectPreferences.fillColor = _DO_NOT_PRINT_Swatches1[s];

tries to assign the name of a color to the fillColor property.

Instead try the following by assigning the color itself and not its name:

 

app.findObjectPreferences.fillColor = 
myDoc.colors.itemByName( _DO_NOT_PRINT_Swatches1[s] );

 

I hope, that your myDoc variable refers to the active document.

 

Regards,
Uwe Laubender

( ACP )

Topics

Scripting

Views

133

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Am facing this error, try to find object fill color.

Community Beginner ,
Jun 25, 2020

Copy link to clipboard

Copied

"Error: Invalid value for set property 'fillColor'. Expected Swatch, String or NothingEnum enumerator, but received in indesign"

 

 

Am facing this error, try to find object fill color.
varmyColors = myDoc.colors;
var_counter = 0;
for(varl=0;l<myColors.length;l++){
if(myColors[l].name.search("DO NOT PRINT","i") >-1 || myColors[l].name.search("DO_NOT_PRINT","i") >-1 || myColors[l].name.search("DONOTPRINT","i") >-1 ){
_counter++;
if (_counter == 1) {
_DO_NOT_PRINT_Swatches.push(myColors[l].name);
_DO_NOT_PRINT_Swatches1.push(myColors[l].name);
}
else{
_DO_NOT_PRINT_Swatches.push("\t\t\t" +myColors[l].name);
_DO_NOT_PRINT_Swatches1.push(myColors[l].name);
}
}
}
for(vars=0;s<_DO_NOT_PRINT_Swatches1.length;s++){
app.findChangeObjectOptions.objectType = ObjectTypes.ALL_FRAMES_TYPE;
app.findObjectPreferences.fillColor = _DO_NOT_PRINT_Swatches1[s];
varresultObject = myDoc.findObject();
if(resultObject.length>0){
var_counter = 0;
for(varobj=0;obj<resultObject.length;obj++){
_counter++;
if(_counter == 1){
_Do_Not_Print_Object_Array.push("page "+resultObject[obj].parentPage.name+"-->"+_DO_NOT_PRINT_Swatches1[s]);
}
else{
_Do_Not_Print_Object_Array.push("\t\t\tpage "+resultObject[obj].parentPage.name+"-->"+_DO_NOT_PRINT_Swatches1[s]);
}
}
}
}
 
Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

Hi,

as far as I can see from your code, this line:

app.findObjectPreferences.fillColor = _DO_NOT_PRINT_Swatches1[s];

tries to assign the name of a color to the fillColor property.

Instead try the following by assigning the color itself and not its name:

 

app.findObjectPreferences.fillColor = 
myDoc.colors.itemByName( _DO_NOT_PRINT_Swatches1[s] );

 

I hope, that your myDoc variable refers to the active document.

 

Regards,
Uwe Laubender

( ACP )

Topics

Scripting

Views

134

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Jun 25, 2020

Copy link to clipboard

Copied

Ir seems you are finding some specific swatch, saving its name and the using it to find some objects. I think the error is on line 

app.findObjectPreferences.fillColor = _DO_NOT_PRINT_Swatches1[s];
Debug and see if this has a valid value when the code reached this point. Maybe the index is wrong.
 
-Manan

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Jun 25, 2020

Copy link to clipboard

Copied

Yes. it valid value. here index is swatches name.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Jun 25, 2020

Copy link to clipboard

Copied

Hi,

as far as I can see from your code, this line:

app.findObjectPreferences.fillColor = _DO_NOT_PRINT_Swatches1[s];

tries to assign the name of a color to the fillColor property.

Instead try the following by assigning the color itself and not its name:

 

app.findObjectPreferences.fillColor = 
myDoc.colors.itemByName( _DO_NOT_PRINT_Swatches1[s] );

 

I hope, that your myDoc variable refers to the active document.

 

Regards,
Uwe Laubender

( ACP )

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Jun 25, 2020

Copy link to clipboard

Copied

I tried this too, but still facing error, but instead of am found one thing,

 

Once try to manual, then the automation working well, but once app quit its shown same.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Jun 25, 2020

Copy link to clipboard

Copied

The error may be from the line below the .fillColor line:

 

varresultObject = myDoc.findObject();

 

You need a space after 'var' at the start. 

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...