Skip to main content
Participant
January 29, 2020
Question

Need Keyboard Shortcuts with FORMS

  • January 29, 2020
  • 1 reply
  • 1408 views

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.

 

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
January 29, 2020

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.

waltg007Author
Participant
January 30, 2020

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!!

try67
Community Expert
Community Expert
January 30, 2020

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;
	}
}