British Transport Police believe the worker was hit by an airgun pellet and are appealing for information over the shooting in Galashiels.
The 33-year-old worker suffered a minor arm injury and needed to attend hospital.
PC Steven Johnstone said: “This was a pretty stupid act which could have had serious consequences”.
He urged anyone who was in the area at the time and had information regarding those responsible to contact the BTP “as a matter of urgency”.