I think you've missed the point. g is not grams here, it's g gravity.
The work done on an object is the dot product of the Force acting on the object and the distance over which it acts.
What oldgranpappy was trying to convey is that you should be only considering the forces that acted on the book along the direction over which work was done against a force.
For instance work in picking up something against gravity is the product of its weight and the height that you pick it up to. How far you carry it, since that direction is perpendicular to the force of gravity, then does not affect the amount of work against gravity.