New South Wales police have charged a 46-year-old man with attempted murder after he allegedly fired an arrow through a window at another man.

The alleged victim, aged 42, was caring for his grandfather on a rural property at Aldaville, near Kempsey on the state's mid-north coast, when the incident occurred.

Police say the 46-year-old attacked the elderly man inside the home before the grandson restrained the attacker and forced him outside.

The grandson then sought refuge inside, locking the windows and doors of the house.

Police say while he was trying to close a bedroom window, the man outside fired an arrow through it, narrowly missing him.

Police arrested the 46-year-old and charged him with attempted murder.

He was refused bail and will appear at the Kempsey Local Court today.