Generally speaking, the child may voice a preference at 12. However, it isn't binding on the judge. As a grandparent, you don't have standing as a general rule. I think you need a consultation with an experience family law attorney regarding your situation.
I am not intending this to be legal advice, because I don't know the particulars of your situation. Call me if you would like to discuss this or other isues.
Basically, you are asking a "trick" question. The technical answer is 18 since the child cannot make decisions until they become an adult.
However, I do agree with Attorney Moore. A child, if done appropriately, can meet with a judge in the judge's chambers and discuss the child's preferences. However, it is not binding on a judge's decision. The decision is the whatever the judge decides is in the child's best interest & that term is not defined in the State of Texas.
Please talk to an experienced family law attorney. You have an uphill battle in attempting to gain custody of a child as a grandparent.
Sign up to receive a 10-part series of useful information and legal advice about the divorce process.