All objections to an indictment for a defect appearing on the face thereof, shall be taken by demurrer to the indictment, and not otherwise, before the issuance of the venire facias in capital cases, and before the jury shall be impaneled in all other cases, and not afterward. The court for any formal defect, may, if it be thought necessary, cause the indictment to be forthwith amended, and thereupon the trial shall proceed as if such defect had not appeared.