• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Need Keyboard Shortcuts with FORMS

New Here ,
Jan 29, 2020 Jan 29, 2020

Copy link to clipboard

Copied

Does anyone have a way to use keyboard shortcuts to change the color of a field?  

 

I am trying to write a VBA code, that takes a status from Excel, and then exports that to a visual color in to the pdf.  I can't use a mouse action because it is coming from a MACRO. 

 

Is there a different way to do something like this?  Maybe change the color of the font?  I am trying to think of many ways to figure this out and I'm drawing a blank.

 

So, here is what I need to do...

Complete an Excel spreadsheet that contains all pertainent data and a RAG (red, amber, green) status field

Map the data from the excel spreadsheet to the corresponding fields in the pdf Form

When I need to map the RAG status of the project -- (this is where I'm stuck) -- how to I tell the pdf to color code a particular text box, radio button, etc to FILL IN the object with a corresponding color from the excel file?

 

I am open to all and any suggestions.

 

Here is the issue, in order for the VBA script to work, coloring filling the object in the PDF must be done through keyboard actions.

 

Thank you so much for any help or insight you can give me.

 

TOPICS
Acrobat SDK and JavaScript

Views

513

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
community guidelines
Community Expert ,
Jan 29, 2020 Jan 29, 2020

Copy link to clipboard

Copied

If you can apply the color name as the value of the field you could then run a script to read those values, delete them and set the field's fill color based on them.

Votes

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
community guidelines
New Here ,
Jan 29, 2020 Jan 29, 2020

Copy link to clipboard

Copied

OH WOW!  This is making me excited.

 

How would I go about finding/writing a script to read those color names and then fill the field with the color?

 

Is there a certain script I need to research?

 

Thank you so much try67!!

Votes

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
community guidelines
Community Expert ,
Jan 30, 2020 Jan 30, 2020

Copy link to clipboard

Copied

The basic code to achieve it is not too complicated. You just need to extend it with all the colors you want to have.

Here's the basic script to convert fields with the text "BLUE" in them to have a blue fill color:

 

 

for (var i=0; i<this.numFields; i++) {
	var f = this.getField(this.getNthFieldName(i));
	if (f==null) continue;
	if (f.valueAsString=="BLUE") {
		f.value = "";
		f.fillColor = color.blue;
	}
}

 

Votes

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
community guidelines
New Here ,
Jan 30, 2020 Jan 30, 2020

Copy link to clipboard

Copied

WOW!

 

Try67 you are incredible.  What an asset!

Do you have any courses that you have created that I can view, sign-up, enroll, whatever?  I'd love to learn more.

Thank you so much for your help.  

Votes

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
community guidelines
Community Expert ,
Jan 30, 2020 Jan 30, 2020

Copy link to clipboard

Copied

LATEST

Not at the moment, but if you're interested in buying custom-made scripts or lessons about scripting feel free to contact me privately via [try6767 at gmail.com].

Votes

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
community guidelines